class MyWidget(DisplayWidget):
    def __init__(self, parent=None):
        super(MyWidget, self).__init__(parent)
        self._executor = ProcessPoolExecutor(max_workers=4)

    def _button_clicked(self):
        future = self._executor.submit(download_data)
        future.add_done_callback(self._populate_textarea)

    def _populate_textarea(self, future):
        self._textarea.setPlainText(future.result())
Exemplo n.º 2
0
    logging.info("Running in %s seconds ...", t - time.time())
    sched.enterabs(t, 0, run, ())
    sched.run()
    return ret[0]


logging.critical(
    "========== ======== =========== ======== ========== ===== =====")
logging.critical(
    "Type       Duration Concurrency Sum      Avg        Min   Max")
logging.critical(
    "========== ======== =========== ======== ========== ===== =====")

for type_ in (
        'redis_lock',
        'native',
):
    for duration in (0, 0.001, 0.01, 0.05, 0.1):
        for concurrency in (1, 2, 3, 4, 5, 6, 12, 24, 48):
            with ProcessPoolExecutor(max_workers=concurrency) as pool:
                t = round(time.time()) + 1
                load = [(t, duration, type_) for _ in range(concurrency)]
                logging.info("Running %s", load)
                ret = [i for i in pool.map(test, load)]

            logging.critical("%10s %-8.3f %-11s %-8s %-10.2f %-5s %-5s", type_,
                             duration, concurrency, sum(ret),
                             sum(ret) / len(ret), min(ret), max(ret))
logging.critical(
    "========== ======== =========== ======== ========== ===== =====")
 def __init__(self, parent=None):
     super(MyWidget, self).__init__(parent)
     self._executor = ProcessPoolExecutor(max_workers=4)