0

My python process listens for files events and trigger an async task.

When a task runs the following output is written to stderr:

Executing <Task pending coro=<process_file() running at /home/adona/SINT/watcher.py:86> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fea5cb0b078>()] created at /usr/lib/python3.6/asyncio/base_events.py:295> created at /home/adona/SINT/watcher.py:67> took 0.350 seconds
Executing <Handle <TaskWakeupMethWrapper object at 0x7fea5e3d7af8>(<Future finis...events.py:295>) created at /home/adona/SINT/penv/lib/python3.6/site-packages/aiohttp/helpers.py:667> took 0.436 seconds
Executing <Handle <TaskWakeupMethWrapper object at 0x7fea5cb0b258>(<Future finis...events.py:295>) created at /home/adona/SINT/penv/lib/python3.6/site-packages/aiohttp/helpers.py:667> took 0.124 seconds

To me it seems a debug o inform message, not a warning or a problem, but please correct me if I'm wrong.

Is there a way to disable python to write on stderr these messages?

The line 86 at watcher.py:

async for df in sint.FEEDER.upload(pname):  # line 86
    if not isinstance(df, pd.DataFrame):
        raise Exception(
            'internal error: file parser does not returns a dataframe')
attdona
  • 17,196
  • 7
  • 49
  • 60
  • 2
    Check this post: https://stackoverflow.com/questions/47476388/what-does-an-executing-handle-taskwakeupmethwrapper-warning-in-python-asy – Mike67 Jul 30 '20 at 14:10
  • The part of execution of a task **between suspends** should never take too long, so the warning might be appropriate. How is this `FEEDER` implemented? – user4815162342 Jul 30 '20 at 19:14

2 Answers2

3

The message is a warning: an async task executed for a long time without yielding control to the event loop.

If this is acceptable and you want avoid this message, set the log level of asyncio package to ERROR:

# disable the asyncio "Executing took ... seconds" warning
logging.getLogger('asyncio').setLevel(logging.ERROR)
attdona
  • 17,196
  • 7
  • 49
  • 60
0

These warnings are only written if you have asyncio Debug Mode enabled, which is not a good idea for production code. It is used (among other things) to help diagnose if you have something blocking your main event loop for longer than 100ms which will slow down execution of other tasks. If you're not concerned about that, or this is production code, the proper fix is to turn off Debug Mode (see the linked docs as the method to turn this off depends on how you have it turned on)

Keith
  • 547
  • 6
  • 14