Added generic multiprocess wrapper
Corrected blocks after timeout function
This commit is contained in:
parent
eb763cf293
commit
061e2d1e01
@ -18,10 +18,14 @@ def get_blocks_by_type(block_type):
|
||||
if block.type == block_type:
|
||||
yield block
|
||||
|
||||
|
||||
def get_blocks_after_timestamp(timestamp: int, block_type: bytes = ''):
|
||||
block_db = db.get_db_obj(block_db_path, 'u')
|
||||
for block_hash in db.list_keys(block_db_path):
|
||||
block = Block(block_hash, block_db[block_hash], auto_verify=False)
|
||||
if block.type == block_type:
|
||||
if block.timestamp > timestamp:
|
||||
if block_type:
|
||||
if block_type == block.type:
|
||||
yield block
|
||||
else:
|
||||
yield block
|
||||
|
||||
|
22
src/onionrprocess/__init__.py
Normal file
22
src/onionrprocess/__init__.py
Normal file
@ -0,0 +1,22 @@
|
||||
from audioop import mul
|
||||
import multiprocessing
|
||||
|
||||
def run_func_in_new_process(func, *args, **kwargs):
|
||||
queue = multiprocessing.Queue()
|
||||
|
||||
def _wrap_func():
|
||||
if args and kwargs:
|
||||
queue.put(func(*args, **kwargs))
|
||||
elif args:
|
||||
queue.put(func(*args))
|
||||
elif kwargs:
|
||||
queue.put(func(**kwargs))
|
||||
else:
|
||||
queue.put(func())
|
||||
|
||||
|
||||
proc = multiprocessing.Process(target=_wrap_func, daemon=True)
|
||||
proc.start()
|
||||
return queue.get()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user