Apr-01-2020, 01:29 PM
Hello,
Hope you are doing well.
I have the following code
Please help me with this.
In general, what I am trying to do is have a daemon load all the static files(which includes a few text files and a huge machine learning model) and use this loaded information repeatedly in a main script.
Thank you for the help
Stay safe
Hope you are doing well.
I have the following code
#!/usr/bin/env python3
# encoding: utf-8
import daemon
import sys
import time
class Loader:
token_length = 0
@staticmethod
def get():
return token_length
@staticmethod
def start():
with daemon.DaemonContext(stdout=sys.stdout):
print("Daemon Started!!")
token_length = 1000
while True:
pass
if __name__ == '__main__':
if 'start' == sys.argv[1]:
Loader.start()
elif 'get' == sys.argv[1]:
print(Loader.get())
else:
print("Invalid option")When I do ./daemon_demo.py start, according to me it should start and assign a value to token_length. Now when I try to access this value using ./daemon_demo.py get, I get an error "NameError: name 'token_length' is not defined".Please help me with this.
In general, what I am trying to do is have a daemon load all the static files(which includes a few text files and a huge machine learning model) and use this loaded information repeatedly in a main script.
Thank you for the help
Stay safe
