Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #301 from kjaymiller/picklefix
Browse files Browse the repository at this point in the history
Force fork method
  • Loading branch information
kjaymiller authored Dec 8, 2023
2 parents a105aa6 + f86115e commit e7c6d74
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions {{cookiecutter.__src_folder_name}}/src/tests/local/conftest.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{# standard library imports #}
{% if cookiecutter.project_backend == "fastapi" %}
from multiprocessing import Process
import multiprocessing
import socket
import time
{% endif %}
{% if cookiecutter.project_backend == "flask" %}
import multiprocessing
import os
import pathlib
from multiprocessing import Process
{% endif %}
{% if cookiecutter.project_backend == "django" %}
import os
Expand Down Expand Up @@ -44,6 +44,11 @@
{% endif %}
{% endif %}

{% if cookiecutter.project_backend in ("flask", "fastapi") %}
# Set start method to "fork" to avoid issues with pickling on OSes that default to "spawn"
multiprocessing.set_start_method("fork")
{% endif %}

{% if cookiecutter.project_backend == "fastapi" %}
def wait_for_server_ready(
url: str, timeout: float = 10.0, check_interval: float = 0.5
Expand Down Expand Up @@ -130,7 +135,7 @@ def live_server_url(app_with_db):
# Start the process
hostname = ephemeral_port_reserve.LOCALHOST
free_port = ephemeral_port_reserve.reserve(hostname)
proc = Process(
proc = multiprocessing.Process(
target=run_server,
args=(
app_with_db,
Expand Down

0 comments on commit e7c6d74

Please sign in to comment.