Skip to content

Commit

Permalink
Tests: Explicitly set multiprocessing start method to "fork"
Browse files Browse the repository at this point in the history
By using multiprocessing's ForkProcess, the testsuite will also start
working on macOS again, even on Python 3.8+.

The background on this is that beginning with Python 3.8+, "fork" is not
the default on all platforms anymore but has been changed to "spawn" on
macOS. This method, however, apparently is not compatible with how 
multiprocessing is currently used within the test harness.
  • Loading branch information
amotl committed Mar 25, 2021
1 parent 973658c commit 89f2315
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/crate/client/test_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import random
import traceback
from http.server import BaseHTTPRequestHandler, HTTPServer
from multiprocessing.context import ForkProcess
from unittest import TestCase
from unittest.mock import patch, MagicMock
from threading import Thread, Event
from multiprocessing import Process
from decimal import Decimal
import datetime as dt
import urllib3.exceptions
Expand Down Expand Up @@ -396,7 +396,7 @@ class KeepAliveClientTest(TestCase):

def __init__(self, *args, **kwargs):
super(KeepAliveClientTest, self).__init__(*args, **kwargs)
self.server_process = Process(target=self._run_server)
self.server_process = ForkProcess(target=self._run_server)

def setUp(self):
super(KeepAliveClientTest, self).setUp()
Expand Down Expand Up @@ -529,8 +529,8 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.assertIsNotNone(self.request_handler)
self.server_address = ('127.0.0.1', random.randint(65000, 65535))
self.server_process = Process(target=TestingHTTPServer.run_server,
args=(self.server_address, self.request_handler))
self.server_process = ForkProcess(target=TestingHTTPServer.run_server,
args=(self.server_address, self.request_handler))

def setUp(self):
self.server_process.start()
Expand Down

0 comments on commit 89f2315

Please sign in to comment.