Skip to content

Conversation

@pedro-psb
Copy link
Member

@pedro-psb pedro-psb commented Oct 31, 2025

We have a complex setup going on.

Task Type | Context Type | Immediate || Adapter Required | Notes                                               |
----------|--------------|-----------||------------------|-----------------------------------------------------|
Async     | Async        | Yes       || No               | Direct execution                                    |
----------|--------------|-----------||------------------|-----------------------------------------------------|
Async     | Sync         | Yes       || Yes              | Async task in sync context needs adapter            |
Async     | Sync         | No        || Yes              | Async task in sync context needs adapter            |
Sync      | Sync         | No        || No               | Direct execution                                    |
----------|--------------|-----------||------------------|-----------------------------------------------------|
Sync      | Sync         | Yes       || Invalid          | Immediate requires async task                       |
Sync      | Async        | Yes       || Invalid          | Immediate requires async task                       |
Sync      | Async        | No        || Invalid          | Always executed in sync context (worker)            |
Async     | Async        | No        || Invalid          | Always executed in sync context (worker)            |

All the logic was being handled in a single function with lots of conditional branches, which was hard to read and reason about. Tthis splits it in more digestable auxiliary functions and tries to make the logic more clear.

@pedro-psb pedro-psb changed the title experiment: remove unnecessary code experiment: cleanup get_task_function Oct 31, 2025
@pedro-psb pedro-psb force-pushed the get-task-function branch 2 times, most recently from 109ec1e to d552134 Compare October 31, 2025 16:14
@pedro-psb pedro-psb changed the title experiment: cleanup get_task_function cleanup get_task_function Oct 31, 2025

return async_to_sync(task_wrapper)
coro = func(*args, **kwargs)
return _add_timeout_to(coro, task.pk)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is nothing really async in this. It's just to enforce it's supposed to be run in async context.

@pedro-psb pedro-psb force-pushed the get-task-function branch 6 times, most recently from ea23eb0 to 16e11a0 Compare November 3, 2025 16:01
@pedro-psb pedro-psb changed the title cleanup get_task_function Refactor get_task_function Nov 3, 2025
@pedro-psb pedro-psb marked this pull request as ready for review November 3, 2025 17:07
@pedro-psb pedro-psb marked this pull request as draft November 3, 2025 21:33
All the logic was being handled in a single function with lots of
conditional branches, which was  hard to read and reason about.
this splits it in more digestable auxiliary functions and tries to
make the logic more clear.
@pedro-psb pedro-psb marked this pull request as ready for review November 4, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants