Skip to content
Myr

Use a condition variable instead of sleeping

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 280d865 · Browse files · 1 file+6 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−3 removed

  • other:+6 added−3 removed

1 file+6 added−3 removed

modified:flask/testsuite/basic.py+6 added-3 removed
13 unmodified lines
14import flask15import pickle16import unittest17from datetime import datetime18from threading import Thread19from time import sleep18from threading import Thread, Condition19from flask.testsuite import FlaskTestCase, emits_module_deprecation_warning20from flask._compat import text_type21from werkzeug.exceptions import BadRequest, NotFound22from werkzeug.http import parse_date
994 unmodified lines
10171018 def test_before_first_request_functions_concurrent(self):1019 got = []1020 app = flask.Flask(__name__)1021 cv = Condition()1022 @app.before_first_request1023 def foo():1024 sleep(1)1024 with cv:1025 cv.wait()1026 got.append(42)1027 c = app.test_client()1028 def get_and_assert():1029 with cv:1030 cv.notify()1031 c.get("/")1032 self.assert_equal(got, [42])1033 t = Thread(target=get_and_assert)1034 t.start()
241 unmodified lines