File tree Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Expand file tree Collapse file tree 4 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 1+ .python_manager.log
2+ __pycache__
3+ * /__pycache__
Original file line number Diff line number Diff line change 11#!/bin/python
22import logging as log
3+ from importlib import import_module
4+ import services
5+ import config
6+ from modules .worker import Worker
37
48LOG_FILENAME = 'python_manager.log'
9+ dynamic_imports = []
10+ worker = Worker ()
11+
12+ class Service ():
13+ def __init__ (self , name ):
14+ self .name = name
515
616def __init__ ():
17+ global dynamic_imports
718 log .basicConfig (filename = LOG_FILENAME ,level = log .DEBUG )
19+ for service in config .run .keys ():
20+ dynamic_imports .append (import_module ('services.%s' % service ))
821
922def main ():
1023 __init__ ()
11- log .warning ("lol" )
24+ for service_name in config .run .keys ():
25+ worker .add (Service (service_name ))
26+ worker .start ()
27+ log .info ('All tasks done. Stopping' )
1228 return 0
1329
1430if __name__ == '__main__' :
Original file line number Diff line number Diff line change 1+ from threading import Thread
2+ import services
3+
4+ class Worker ():
5+ def __init__ (self ):
6+ self .threads = []
7+ self .services = []
8+
9+ def run_service (self , service ):
10+ eval ("services.%s.main()" % service .name )
11+
12+ def start (self ):
13+ for service in self .services :
14+ t = Thread (target = self .run_service , args = [service ])
15+ self .threads .append (t )
16+ t .start ()
17+
18+ def add (self , service ):
19+ self .services .append (service )
20+
21+
Original file line number Diff line number Diff line change 1+ #!/bin/python
2+
3+ def main (args = None ):
4+ print ("hello world" )
5+ return 0
6+
7+ if __name__ == "__main__" :
8+ main ()
You can’t perform that action at this time.
0 commit comments