Logging with 2 process in application
Chris Angelico
rosuav at gmail.com
Mon Feb 22 01:03:27 EST 2021
On Mon, Feb 22, 2021 at 5:01 PM gayatri funde <fundegayatri at gmail.com> wrote:
> I have 2 files mainModule.py and loggingModule.py files as below:
> In loggingModule.py file i am managing new log to create , which i am importing to mainModule.py file.
>
> def child_Process(var1):
> while True:
> time.sleep(10)
> logging.info('Log from Child Process')
>
> if __name__ == "__main__":
> var1 = "LotsOfSunshine"
> time.sleep(1)
> logging.info("Log from Main process")
>
> child_Multiprocess = multiprocessing.Process(target=child_Process, args=(var1,))
> child_Multiprocess.start()
>
When you spawn a subprocess, its variables are completely separate
from the parent. I suspect that you'll do far FAR better with
threading here, rather than trying to share things across processes.
ChrisA
More information about the Python-list
mailing list