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

Documentation for version 3.0* (Worker Quickstart) is not up to date #194

Closed
tomas-zemres opened this issue Jul 28, 2021 · 3 comments
Closed
Labels

Comments

@tomas-zemres
Copy link

I tried the exmple from the documentation for pyzeebe 3.0.0.

https://pyzeebe.readthedocs.io/en/pre-release-3.0.0/worker_quickstart.html#create-and-start-a-worker

import asyncio

from pyzeebe import ZeebeWorker


worker = ZeebeWorker()


@worker.task(task_type="my_task")
async def my_task(x: int):
    return {"y": x + 1}

asyncio.run(worker.work())

I used pyzeebe 3.0.0rc3

It raises exception:

Traceback (most recent call last):
  File "./pyzeebe-example.py", line 6, in <module>
    worker = ZeebeWorker()
TypeError: __init__() missing 1 required positional argument: 'grpc_channel'
@JonatanMartens
Copy link
Collaborator

Fixed :)

@tomas-zemres
Copy link
Author

Thanks for fast fix, but is it still not working with python 3.8

There are two different examples and both raises exception.

1. On the page https://pyzeebe.readthedocs.io/en/pre-release-3.0.0/ is

from pyzeebe import ZeebeWorker, create_insecure_channel

channel = create_insecure_channel()
worker = ZeebeWorker(channel)

@worker.task(task_type="my_task")
async def my_task(x: int):
   return {"y": x + 1}

await worker.work()

That raises exception

  File "/home/developer/test/pyzeebe-example2.py", line 10
    await worker.work()
    ^
SyntaxError: 'await' outside function

2. On the page https://pyzeebe.readthedocs.io/en/pre-release-3.0.0/worker_quickstart.html#create-and-start-a-worker is

import asyncio

from pyzeebe import ZeebeWorker, create_insecure_channel

channel = create_insecure_channel()
worker = ZeebeWorker(channel)


@worker.task(task_type="my_task")
async def my_task(x: int):
    return {"y": x + 1}

asyncio.run(worker.work())

That raises exception

  File "/home/developer/test/pyzeebe-example2.py", line 13, in <module>
    asyncio.run(worker.work())
  File "/opt/python-3.8/lib/python3.8/asyncio/runners.py", line 43, in run
    return loop.run_until_complete(main)
  File "/opt/python-3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "/home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/pyzeebe/worker/worker.py", line 86, in work
    return await asyncio.gather(*coroutines)
  File "/home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/pyzeebe/worker/job_poller.py", line 28, in poll
    await self.poll_once()
  File "/home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/pyzeebe/worker/job_poller.py", line 40, in poll_once
    async for job in jobs:
  File "/home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/pyzeebe/grpc_internals/zeebe_job_adapter.py", line 23, in activate_jobs
    async for response in self._gateway_stub.ActivateJobs(
  File "/home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/grpc/aio/_call.py", line 315, in _fetch_stream_responses
    message = await self._read()
  File "/home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/grpc/aio/_call.py", line 331, in _read
    await self._preparation
RuntimeError: Task <Task pending name='Task-2' coro=<JobPoller.poll() running at /home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/pyzeebe/worker/job_poller.py:28> cb=[gather.<locals>._done_callback() at /opt/python-3.8/lib/python3.8/asyncio/tasks.py:751]> got Future <Task pending name='Task-4' coro=<UnaryStreamCall._send_unary_request() running at /home/developer/.local/share/virtualenvs/test-xMQI-GAt/lib/python3.8/site-packages/grpc/aio/_call.py:539>> attached to a different loop

Note that we use python 3.8 & pyzeebe 3.0.0rc3

@JonatanMartens
Copy link
Collaborator

See #198

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

No branches or pull requests

2 participants