File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 2
2
# -*- coding: utf-8 -*-
3
3
4
4
import ipaddress
5
+ import multiprocessing
5
6
import os
6
7
import pathlib
7
8
import threading
@@ -45,6 +46,7 @@ class BaseTestReader(object):
45
46
Type ["maxminddb.extension.Reader" ], Type ["maxminddb.reader.Reader" ]
46
47
]
47
48
use_ip_objects = False
49
+ mp = multiprocessing .get_context ("fork" )
48
50
49
51
def ipf (self , ip ):
50
52
if self .use_ip_objects :
@@ -441,7 +443,7 @@ def test_closed_metadata(self):
441
443
self .assertIsNotNone (metadata , "pure Python implementation returns value" )
442
444
443
445
def test_multiprocessing (self ):
444
- self ._check_concurrency (Process )
446
+ self ._check_concurrency (self . mp . Process )
445
447
446
448
def test_threading (self ):
447
449
self ._check_concurrency (threading .Thread )
@@ -459,11 +461,11 @@ def lookup(pipe):
459
461
except :
460
462
pipe .send (0 )
461
463
finally :
462
- if worker_class is Process :
464
+ if worker_class is self . mp . Process :
463
465
reader .close ()
464
466
pipe .close ()
465
467
466
- pipes = [Pipe () for _ in range (32 )]
468
+ pipes = [self . mp . Pipe () for _ in range (32 )]
467
469
procs = [worker_class (target = lookup , args = (c ,)) for (p , c ) in pipes ]
468
470
for proc in procs :
469
471
proc .start ()
You can’t perform that action at this time.
0 commit comments