I'm writing my code using asyncio module with a lot of info/debug logging (logging.FileHandler). I'm concerned that extensive using of logging in asyncio will decrease the performance of my application, because logging is blocking operation.
What is the best solution for that? Didn't find any information on logging overhead.
Maybe using SocketHandler or MemoryHandler will help? For metrics I'm using statsd (which is also blocking operation, but must be very fast), but I'm more concerned with non-blocking logging.
Code example:
@asyncio.coroutine
def creator_worker(self):
while not self.q.empty():
with (yield from self.semaphore):
sample = yield from self.q.get()
logging.debug('Got new sample, processing')
# start processing
I'm aware of
import os
os.environ['PYTHONASYNCIODEBUG'] = '1'
import asyncio
But that's not what I'm looking for.
Thank you