Uses the original (unpatched) os.write to avoid issues with eventlet/gevent monkey-patching. When using eventlet>=0.37.0, the patched os.write calls hubs.trampoline() which raises RuntimeError if called from within the hub's event loop (e.g., during signal handling).
(msg, f=sys.__stderr__)
| 78 | |
| 79 | |
| 80 | def safe_say(msg, f=sys.__stderr__): |
| 81 | """ |
| 82 | Uses the original (unpatched) os.write to avoid issues with eventlet/gevent |
| 83 | monkey-patching. When using eventlet>=0.37.0, the patched os.write calls |
| 84 | hubs.trampoline() which raises RuntimeError if called from within the |
| 85 | hub's event loop (e.g., during signal handling). |
| 86 | """ |
| 87 | if hasattr(f, 'fileno') and f.fileno() is not None: |
| 88 | _original_os_write(f.fileno(), f'\n{msg}\n'.encode()) |
| 89 | |
| 90 | |
| 91 | class Worker(WorkController): |