tobymao / saq

Simple Async Queues
https://saq-py.readthedocs.io/en/latest/
MIT License
532 stars 37 forks source link

Error a long task #50

Closed genfild closed 1 year ago

genfild commented 1 year ago

I start a long task using a framework PlayWright

ERROR:saq:Error processing job Job<function=fgis, kwargs={'cmd': 'parse', 'cn': '67:17:0010333:59'}, queue=fgis, id=saq:job:fgis:57646e99-7bcd-11ed-b618-2d9cfaea7267, scheduled=0, progress=0.0, start_ms=23, attempts=1, status=active, meta={}>
Traceback (most recent call last):
  File "/root/playwright/saq_srv.py", line 18, in fgis
    return await w.job(cmd, **kvargs)
  File "/root/playwright/rosreestr/fgis/worker.py", line 51, in job
    self.current = await self.search.cadnum(cn, regions[cn[:2]])
  File "/root/playwright/rosreestr/fgis/_page/search.py", line 14, in cadnum
    await page.locator(".v-filterselect-input").first.type(region, delay=100)
  File "/root/playwright/.pw/lib/python3.10/site-packages/playwright/async_api/_generated.py", line 15250, in type
    await self._impl_obj.type(
  File "/root/playwright/.pw/lib/python3.10/site-packages/playwright/_impl/_locator.py", line 558, in type
    return await self._frame.type(
  File "/root/playwright/.pw/lib/python3.10/site-packages/playwright/_impl/_frame.py", line 710, in type
    await self._channel.send("type", locals_to_params(locals()))
  File "/root/playwright/.pw/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 44, in send
    return await self._connection.wrap_api_call(
  File "/root/playwright/.pw/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 419, in wrap_api_call
    return await cb()
  File "/root/playwright/.pw/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 70, in inner_send
    done, _ = await asyncio.wait(
  File "/usr/lib/python3.10/asyncio/tasks.py", line 384, in wait
    return await _wait(fs, timeout, return_when, loop)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 491, in _wait
    await waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/asyncio/tasks.py", line 456, in wait_for
    return fut.result()
asyncio.exceptions.CancelledError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/root/playwright/.pw/lib/python3.10/site-packages/saq/worker.py", line 247, in process
    result = await asyncio.wait_for(task, job.timeout)
  File "/usr/lib/python3.10/asyncio/tasks.py", line 458, in wait_for
    raise exceptions.TimeoutError() from exc
asyncio.exceptions.TimeoutError
tobymao commented 1 year ago

the default timeout is 10 seconds, you can set this to be much longer or even infinite https://github.com/tobymao/saq/blob/master/saq/job.py#L65

genfild commented 1 year ago

Something timeout is not working

print(await queue.enqueue('fgis', cmd = 'parse', cn = '67:17:0010333:59', timeout=0) )
...
Job<function=fgis, kwargs={'cmd': 'parse', 'cn': '67:17:0010333:59'}, queue=fgis, id=saq:job:fgis:e44ddb81-7c3d-11ed-b618-2d9cfaea7267, scheduled=0, progress=0.0, attempts=0, status=queued, meta={}>
tobymao commented 1 year ago

can you try commit 3d130dcf?