Closed wmeijer221 closed 1 year ago
I explored the problem a little further.
When using other logging tools (e.g. logging
), the same thing happens.
When launching the worker in a separate thread, the prints in the main thread seem to work, but the prints in the worker threads don't.
I'm starting to think this issue is more of a bug in ExternalTaskWorker
than anything else. Maybe the workers are somehow blocking stdout
?
Edit: After a little more exploration, I figured out that the following works:
import logging
logging.root.setLevel(logging.NOTSET)
logger = logging.getLogger(__name__)
So overwriting the logging level and then using the logging
package works.
I'm not too familiar with the logging
package, so I'm not too sure whether this is by design or not.
It might be worth explicitly noting down somewhere in the README
that you should use logging
or log_with_context
for your logs, though.
I've implemented a simple external task client in Python and docker-compose. However, none of my
print()
statements seem to appear in the console.The code I wrote is rather straightforward:
I learned that whenever I remove the last two lines (i.e. the ones creating/using
worker
), the prints show up just fine. Additionally, whenever I attach myself to the client's docker instance (usingdocker attach
) and then cause aKeyboardInterrupt
, the logs do show up. So they are printed at some point, just not at runtime.Does anyone know how I can use
print()
in combination withExternalTaskWorker
? (Thanks in advance!)Note that the code works just fine; whenever I create a task the client is interested in, it completes it.
In case it's relevant, this is the docker-compose I'm using: