Write by logging.FileHandler to one file by many processess

G

Guest

Hello.

As I saw in logging source - there is no lock per file during making emit()
(only lock per thread).

So, my question is - is it safe to log into one file using many processess
uses logging logger?

Cheers,
 
A

Alexandre Badez

Hello.

As I saw in logging source - there is no lock per file during making emit()
(only lock per thread).

So, my question is - is it safe to log into one file using many processess
uses logging logger?

Cheers,

Well, there a dummy response: there is no true thread in Python (I
mean CPython). So there is no problems in this case (cf global
interpreter lock or GIL).
 
D

Diez B. Roggisch

Alexandre said:
Well, there a dummy response: there is no true thread in Python (I
mean CPython). So there is no problems in this case (cf global
interpreter lock or GIL).

You didn't read the statement of the OP - he explicitly doesn't ask about
threads, but multiple processes writing to one file.

I presume things get messed up... but I don't know for sure.

Diez
 
G

Gabriel Genellina

I presume things get messed up... but I don't know for sure.

Yes, output from several processes comes horribly mixed...
I've avoided it using separate log files for each process; but if that's
not possible, one could try using syslog or a SocketHandler and a separate
listening process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top