David K. Hess <david_k_h...@mac.com> added the comment:

I’m not sure I can shed any light on this particular bug, but I would say that 
based on my dealings with this module, it is definitely not thread-safe. That 
means that if you are going to have multiple threads accessing it 
simultaneously, you really should have a mutex around that access ensuring only 
one thread is running through the code in this module at a time. 

Now in reality, asyncio and other cooperatively scheduled multi-processing 
packages like gevent are not going to unpredictably yield control to another 
thread like true threads will. So, in this particular case, since the init code 
doesn’t use async or await, I don’t think there is a chance of an 
initialization race bug there. 

As to the bug witnessed, the only thing I can suggest is to add a considerable 
amount of debugging that logs the argument to guess_type and prints out the 
mimetype module’s internal state if and when this happens again. My best guess 
based on the amount of work that method does to inspect the passed in url, is 
that it has something to do with the url itself.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40139>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to