def req_pids_procs(): pids = TaskManager.get_instance().get_pids() result = 'pids: {}'.format(os.getpid()) for pid in pids: result += ' {}'.format(pid) result += '\n' return result
def main(): print( 'This is a local test suite based in inputs. Works without telegram connection' ) print(' Type /exit or /quit to exit.') print(' Type /dbs [key_pattern] to view redis database.') print(' Type /kill <user_id> to delete the user.') print(' Type /reset to reset the dialog state.') print(' Type /chuser <user_id> to change current user ID') print(' Type /loc <latitude> <longitude> to send location.') print('\n') user_id = input('User ID? (Press enter for default):').strip() if not user_id: user_id = 102 else: user_id = int(user_id) print(f'Your user ID is {user_id}!') config = Config() logging.basicConfig( level=logging.INFO if config.is_debug else logging.ERROR) loop = asyncio.get_event_loop() loop.run_until_complete(DB().connect()) sender = PrintSender() handlers = get_message_handlers(globals()) message_handler = MessageHandler(handlers, initial_handler=ENTRY_POINT, command_handler=CommandHandler(), sender=sender) task_manager = TaskManager(message_handler) task_manager.run_on_loop(loop) inputs_bot = BotOnInputs(message_handler, sender, user_id) loop.run_until_complete(inputs_bot.repl_loop())
def kill_pids_procs(): log_info('$CYAN#####################################################################$RESET') log_info('$CYAN Kill all process $RESET') log_info('$CYAN#####################################################################$RESET') flask_pid = os.getpid() pids = TaskManager.get_instance().get_pids() for pid in pids: p = psutil.Process(pid) p.terminate() log_info # flask kill pid p = psutil.Process(flask_pid) p.terminate() return 'kill all process'
# -*- coding: utf-8 -*- import os import json import sys from tasks.task_manager import TaskManager from tasks.task import Task from tasks.grayscale import Grayscale from tasks.folder import Folder from tasks.texture_atlas import TextureAtlas mgr = TaskManager() mgr.register_task('grayscale', Grayscale) mgr.register_task('folder', Folder) mgr.register_task('texture_atlas', TextureAtlas) if __name__ == '__main__': filename = sys.argv[1] data = json.load(file(filename, 'r')) for uuid, values in data.items(): mgr.create_task(values['name'], uuid, values) mgr.run()
"""HTTP-Server for image processing tool """ import rw.http from rw import gen import json from tasks.task_manager import TaskManager from tasks.task import Task from tasks.grayscale import Grayscale from tasks.folder import Folder from tasks.texture_atlas import TextureAtlas mgr = TaskManager() mgr.register_task('grayscale', Grayscale) mgr.register_task('folder', Folder) mgr.register_task('texture_atlas', TextureAtlas) root = rw.http.Module('image_processing') @root.get('/') def index(handler): root.render_template('index.html') @root.post('/run') def start_run(handler): data = json.loads(handler.get_argument('data')) for uuid, values in data.items(): mgr.create_task(values['name'], uuid, values)
from nlp_utils import NlpUtils from repositories.postgres_utils import PostgresUtils from repositories.queue_utils import QueueUtils from tasks.review_processor_task import ReviewProcessorTask from tasks.task_manager import TaskManager if __name__ == '__main__': task_manager = TaskManager() # new_movie_task = AddNewMovieToQueueTask(QueueUtils()) # movie_fetcher = MovieFetcherTask(QueueUtils(), RedisUtils('127.0.0.1')) # review_fetcher = ReviewFetcherTask(QueueUtils()) review_processor = ReviewProcessorTask(QueueUtils(), NlpUtils(), PostgresUtils()) # task_manager.add_task(new_movie_task) # task_manager.add_task(movie_fetcher) # task_manager.add_task(review_fetcher) task_manager.add_task(review_processor) task_manager.start()
def req_stop_procs(): TaskManager.get_instance().stop_services() return "stop"
def req_pause_procs(): TaskManager.get_instance().pause_services() return "pause"
def req_load_procs(): TaskManager.get_instance().load_services('./profiles/task_profile.json') return "loading..."