Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add synchronous mode for easier debugging #10

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

rgasper
Copy link
Contributor

@rgasper rgasper commented Nov 6, 2024

My teammates and I have been running into situations where debugging code inside wakaq workers that's getting called via func.delay() in our webserver process feels more painful than necessary.

I'm hoping a small change like this or something similar could dramatically simplify the process by just letting us slap breakpoints in the code and be able to easily run the functions for debugging/development right in the same webserver process that's calling func.delay().

  • Changes to readme not included, pending some kind of approval.
  • Some thought also likely needed for what to do with broadcast and _enqueued_with_eta submissions in synchronous mode.

tested via setting up a venv and running the example from the readme in synchronous mode vs not:

python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# copy example from requirements to test.py
python test.py
> # fails at my_task.delay w/ no redis connection
# set synchronous_mode = True in WakaQ constructor call
python test.py
> 2
> 2
> hello_world
> hello_world  # returns with no delay, delay doesn't work in synchronous mode

I'm certainly sensitive to the motivation for not wanting more features in wakaq- it's simplicity is definitely part of why I like it. I hope this isn't in competition with that spirit. Let me know if it is.

@alanhamlett alanhamlett merged commit 763e401 into wakatime:main Nov 7, 2024
@alanhamlett
Copy link
Member

I log the params from tasks which raised errors, then test it locally running the task without delay func(). This looks useful too.

@alanhamlett
Copy link
Member

Released in https://github.com/wakatime/wakaq/releases/tag/2.1.25

@alanhamlett
Copy link
Member

alanhamlett commented Nov 13, 2024

Heads up, synchronous_mode was removed in v3.0.0 released today because it's not compatible with asyncio tasks. The mocked WakaQ provides the same functionality... wherever you initialize WakaQ just initialize the mocked WakaQ instead of passing synchronous_mode=True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants