-
Notifications
You must be signed in to change notification settings - Fork 37
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
Asyncio ZeebeWorker support #143
Comments
I think adding async support as a separate module would be the way to go. It would allow us to introduce this without changing the current implementation, and get some real-world usage experiences around async. We also wouldn't have to worry about breaking changes when first implementing async, as there would be nothing to break. We could then later replace the thread-based worker if it makes sense. Wonder if it then also makes sense to specify Before using Pyzeebe at NEP, we implemented a PoC around Zeebe workers with Trio. It offers some very useful functionality with regards to task management (https://trio.readthedocs.io/en/stable/tutorial.html#okay-let-s-see-something-cool-already). That's also one consideration that should be made with regards to which async framework to use. I know Trio has some compatibility libraries that allows you to use Trio with AsyncIO. |
I really like this plan to add async support. Polling for jobs is by definition an IO process, very well suited for asynchronous programming. It was clearly something I checked when I first started looking into this project and it might encourage a lot more people to use it. @JonatanMartens I don't think any new thread should be spawned for an async task handler. It is the responsibility of the programmer not to use any blocking operation in a async function (in your example that would mean replacing @kbakk Concerning the async framework, why not simply use native asyncio? Most async framework I know were created to compensate on missing features in Python's early days with async. Unless I'm missing something or unless this library is planning on supporting old versions of Python (support of 3.6 might need to be dropped to be able to use asyncio, some major change were introduced with Python 3.7), asyncio is plenty sufficient and remove the need of adding an external dependency. I've just started using this project so I'm sorry if my early assumption made me misjudge something :) |
Released in v3.0.0 |
Is your feature request related to a problem? Please describe.
pyzeebe
currently has no support for writing async tasks. I believe that asyncio could greatly increasepyzeebe
's usability and developer friendliness.Describe the solution you'd like
In addition to expressing regular tasks like this:
We should also support doing this:
I would also suggest splitting the current
ZeebeWorker
class into two classes:JobPoller
class who is responsible for polling the gateway for jobs.ZeebeWorker
class (minus the job polling responsibility).Each registered task would run two threads:
JobPoller
await
keyword. This is something I'm not entirely certain about (see below)asyncio.loop.run_in_executor
This would mean that something like this:
would block the event loop. We might therefore still consider spawning a thread for each job.
Zeebe-grpc
Currently we are using
zeebe-grpc
under the hood to communicate to the Zeebe gateway. This library currently has no support for asyncio, so we may want to implement it ourselves.Describe alternatives you've considered
Introduce
AsyncZeebeWorker
, which would support async tasks. I'm not sure this is ideal, but it would make sure there are no breaking changes (which will happen anyway withpyzeebe
3.0.0).The text was updated successfully, but these errors were encountered: