I've been doing a lot of OPENTSDB data import work today. In the middle of a number of issues worth recording, here is a good way to remember tomorrow to tidy up
1. Multi-Process Logger
Python's logging module does not support multiple processes, but we can use the Syslog module to write the process to the Linux/unix syslog service.
The syslog has a local 0-7 8 channels. Configure a channel to your log file and write to it.
2. Multi-process
Apply_async This function is a bit strange. The following code, DF if it is a string, is possible. If it is not a string, the child process does not seem to run:
#!/usr/bin/python__author__='Mingwli'ImportsyslogImportMultiprocessing fromMultiprocessingImportPoolImportPydevdsyslog.openlog ('File:%s'%"My File", 0, Syslog. LOG_LOCAL0)defWrite_log (f): Syslog.syslog ('Log msg:%s'%'Test msg') Pool= Pool (processes=20) Result=[]mylist= Range (0, 20) forDfinchmylist:result.append (Pool.apply_async (Write_log, (str (DF)))) Pool.close () Pool.join ()Print " All done"
TSDB Import Related