-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspawn_types.py
More file actions
34 lines (25 loc) · 745 Bytes
/
spawn_types.py
File metadata and controls
34 lines (25 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
'''
types.py - provider of specific types
Types defined in this module:
PrecisionAction(argparse.Action)
'''
import argparse
import logging
import multiprocessing as mp
import multiprocessing.pool as pool
def check_positive(value):
'''Predicate which checks if the argument can be treated as positive int'''
ivalue = int(value)
if ivalue <= 0:
raise argparse.ArgumentTypeError('invalid positive int value: %s' % ivalue)
return ivalue
class NoDaemonProcess(mp.Process):
''' Just like multiprocessing.Process, only non-daemonic'''
@property
def daemon(self):
return False
@daemon.setter
def daemon(self, value):
pass
class NoDaemonPool(pool.Pool):
Process = NoDaemonProcess