Oct-20-2019, 05:15 PM
The thing is, I'm trying to get a process inside my script and have me call it whenever I want. For example, I'm filling in some data and I enter the word "background". In this way, it is called a process that is always active. I leave my code in python, I have created a decorator but I get the following error: "EOFError".
Besides that, it should work both ways, when I'm in the background and insert "background", it should return to the main function.
I share with you the code I've been doing:
Thank you very much!
Besides that, it should work both ways, when I'm in the background and insert "background", it should return to the main function.
I share with you the code I've been doing:
#!/usr/bin/env python # -*- coding: utf-8 -*- import os, time def daemonLife(func): def wrapper(*args, **kwargs): if os.fork(): return func(*args, **kwargs) os._exit(os.EX_OK) return wrapper @daemonLife def my_func(): no_kill_nothing = "Hi!" print('pid of it: %d' % os.getppid()) var2 = str(input("Inside of background!")) if var2 == "background": main(no_kill_nothing) def main(text): if text == "background": my_func() text = str(input("Insert something")) main(text)I tried multi-threading because I think it's more ideal but I haven't been able to.
Thank you very much!