Describe the bug
When Rocketry works in async fashion through app.serve(), it becomes frozen when specific manual-run task sequence is executed.
Task sequence:
run_me_madam starts on async
run_me_madam finishes
run_me_sir starts on process (not async)
app.serve() becomes frozen
To Reproduce
For reproducing the bug I will paste code at the bottom of issue and will pinpoint commit, after which the aforementioned bug arose.
Expected behavior
starting manually a task after one has finished, should not freeze the async Rocketry.serve(). In this case it is expected to see run_me_sir finish.
Screenshots
When trying to KeyboardInterrupt the frozen async Rocketry.serve(), such error always appears:
Desktop (please complete the following information):
OS: Windows 10 Home
Python version 3.10.4
On Rocketry v2.4.1 bug does not exist.
On Rocketry v2.5.0, v2.5.1 and latest codebase bug does exist
Specific commit, that introduces the bug: pip install git+https://github.com/Miksus/rocketry.git@c9480a9c847704a0a57b4c6770eeb1028bf029a0
Additional context
Here I paste the code.
from time import sleep
import asyncio
from rocketry import Rocketry
# #
# Rocketry app
app = Rocketry(
config={
"execution": "async",
"max_process_count": 100,
}
)
# #
# tasks
@app.task("every 10 seconds")
async def mark_10_seconds():
print("10 seconds have passed")
@app.task(execution="async")
async def run_me_madam():
print("Madam, I am going to sleep for 2 seconds")
sleep(2)
print("Madam, I am done with sleeping")
@app.task(execution="process")
async def run_me_sir():
print(f"Sir, I am going to sleep for 2 seconds.")
sleep(2)
print("Sir, I am done with sleeping")
if __name__ == "__main__":
async def task_manual_run_flow():
await asyncio.sleep(3)
print(
"will run run_me_madam task - on async (or even if on process, result would be the same)"
)
app.session["run_me_madam"].run()
await asyncio.sleep(10)
print("madam task should be done by now")
print("will run run_me_sir - on process")
app.session["run_me_sir"].run()
print("doing await asyncio.sleep(5). If it takes forever, you are stuck here.")
await asyncio.sleep(5)
print(
"launched run me sir through session. If you do not see this message, it means that app.serve() never returned control via await."
)
async def main_main():
return await asyncio.gather(app.serve(), task_manual_run_flow())
asyncio.run(main_main())
Describe the bug When Rocketry works in async fashion through app.serve(), it becomes frozen when specific manual-run task sequence is executed. Task sequence:
run_me_madam
starts on asyncrun_me_madam
finishesrun_me_sir
starts on process (not async)app.serve()
becomes frozenTo Reproduce For reproducing the bug I will paste code at the bottom of issue and will pinpoint commit, after which the aforementioned bug arose.
Expected behavior starting manually a task after one has finished, should not freeze the async
Rocketry.serve()
. In this case it is expected to seerun_me_sir
finish.Screenshots When trying to KeyboardInterrupt the frozen async
Rocketry.serve()
, such error always appears:Desktop (please complete the following information):
pip install git+https://github.com/Miksus/rocketry.git@c9480a9c847704a0a57b4c6770eeb1028bf029a0
Additional context Here I paste the code.