Example #1
0
def get_environment_status(env_dict, exclude_labels=None):
    """
    Get the environment status per kind in KINDS and save it in a dictionary

    Args:
        env_dict (dict): Dictionary that is a copy.deepcopy(ENV_STATUS_DICT)
        exclude_labels (list): App labels to ignore leftovers
    """
    with ThreadPoolExecutor(max_workers=len(KINDS)) as executor:
        for key, kind in zip(env_dict.keys(), KINDS):
            executor.submit(
                assign_get_values, env_dict, key, kind,
                exclude_labels=exclude_labels
            )
Example #2
0
# All rights reserved.

import logging
import time
from multiprocessing import Process

USE_GEVENT = True

if USE_GEVENT:
    import gevent
    as_completed = gevent.wait
    from gevent.threadpool import ThreadPoolExecutor as ThreadPoolExecutor
else:
    from concurrent.futures import ThreadPoolExecutor, as_completed

pool = ThreadPoolExecutor(32)

from kafka_rpc import KRPCClient
from kafka_rpc import KRPCServer

NUMS = 1000

# 213.8162382121568, no concurrent
# 419.71660475278094, no concurrent, use_redis
# 383.26126764939164, no concurrent, use_redis, has verification and encryption

# 2549.6978760136653, threadpool, poolsize 128
# 3408.9112918300966, threadpool, poolsize 64
# 6788.747358099728, threadpool, poolsize 32
# 2777.8816114784295, threadpool, poolsize 16
Example #3
0
def launch():
	global loop
	loop = GLibEventLoop(context=GLib.MainContext.default())
	executor = ThreadPoolExecutor(max_workers=1)
	executor.submit(worker)
Simulate a situation when multiple threads of Kafka RPC Client send request to Kafka RPC Server
"""

USE_GEVENT = True

if USE_GEVENT:
    import gevent
    as_completed = gevent.wait
    from gevent.threadpool import ThreadPoolExecutor as ThreadPoolExecutor
else:
    from concurrent.futures import ThreadPoolExecutor, as_completed

from kafka_rpc import KRPCClient

pool = ThreadPoolExecutor(128)

# assuming you kafka broker is on localhost:9092
krc = KRPCClient('localhost:9092', topic_name='sum')

# call method concurrently from client to server
# use pool.map if you like
futures = []
for i in range(128):
    futures.append(pool.submit(krc.add, 1, 2, timeout=20))

for future in as_completed(futures):
    result = future.result()
    print(result)

krc.close()
Example #5
0
def launch():
    executor = ThreadPoolExecutor(max_workers=1)
    executor.submit(worker)
Example #6
0
from server import socketio
from collections import Counter
from gevent.threadpool import ThreadPoolExecutor
from configparser import ConfigParser
from server import config_file

# プログラミング言語と拡張子の対応表
lang_to_extension = {
    "Python3": ".py",
    "Java": ".java",
    "C": ".c",
    "C++": ".cpp"
}

# スレッドプール
executor = ThreadPoolExecutor(
    max_workers=int(config_file["system"]["max_worker"]))


def judge_code(submission_id):
    """提出されたコードをジャッジする

    Args:
        submission_id (str) : 提出ID

    Returns:
        None
    """

    # ジャッジ開始
    start_judge(submission_id)
Example #7
0
def thread_pool_main(interface_info):
    thread_obj = ThreadPoolExecutor(max_workers=1,
                                    thread_name_prefix="WorkExecutor")
    # logger.info("Master ThreadPool Executor starts thread worker")
    thread_obj.submit(get_response(interface_info))