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

Grpc channel created in different event loop #198

Closed
JonatanMartens opened this issue Jul 30, 2021 · 1 comment
Closed

Grpc channel created in different event loop #198

JonatanMartens opened this issue Jul 30, 2021 · 1 comment
Labels
3.0.0 Will be released in Zeebe 3.0.0 bug Something isn't working

Comments

@JonatanMartens
Copy link
Collaborator

Describe the bug
When running a ZeebeWorker using asyncio.run a RuntimeError will be raised with the message attached to a different event loop.

This happens in version 3.0.0rc3 after we removed the channel creation from the worker.

To Reproduce

  1. Install pyzeebe version 3.0.0rc3 (pip install -U pyzeebe=3.0.0rc3)
  2. Run the following code:
    import asyncio
    
    from pyzeebe import ZeebeWorker, create_insecure_channel
    
    
    channel = create_insecure_channel()
    worker = ZeebeWorker(channel)
    
    
    @worker.task("test")
    def test():
        return {}
    
    
     asyncio.run(worker.work())

Workarounds

Create the channel and worker in an async function:

async def main():
    channel = create_insecure_channel()
    worker = ZeebeWorker(channel)

asyncio.run(main())

Or use a loop:

loop = asyncio.get_running_loop()  # or get_event_loop(). This will get the loop in which the grpc.aio.Channel object was created
loop.run_until_complete(worker.work())
@JonatanMartens JonatanMartens added 3.0.0 Will be released in Zeebe 3.0.0 bug Something isn't working and removed triage labels Jul 30, 2021
@JonatanMartens JonatanMartens changed the title Grpc channel exists has different event loop Grpc channel created in different event loop Jul 30, 2021
@JonatanMartens
Copy link
Collaborator Author

Fixed in docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0.0 Will be released in Zeebe 3.0.0 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant