Skip to content

Commit

Permalink
Move application worker definition to the top level of a module
Browse files Browse the repository at this point in the history
As per https://docs.python.org/3/library/pickle.html#what-can-be-pickled-and-unpickled
the only top level function can be pickled. Re #54.
  • Loading branch information
vitalk committed Dec 9, 2016
1 parent 5048d0c commit 8e4b599
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pytest_flask/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def test_login(self):
request.cls.client = client


def _app_worker(app, port):
app.run(port=port, use_reloader=False)


class LiveServer(object):
"""The helper class uses to manage live server. Handles creation and
stopping application in a separate process.
Expand All @@ -56,10 +60,8 @@ def __init__(self, app, port):

def start(self):
"""Start application in a separate process."""
def worker(app, port):
app.run(port=port, use_reloader=False)
self._process = multiprocessing.Process(
target=worker,
target=_app_worker,
args=(self.app, self.port)
)
self._process.start()
Expand Down

0 comments on commit 8e4b599

Please sign in to comment.