Skip to content

Commit 95b893e

Browse files
authored
Merge pull request #21 from Mathutor/Fix/issue-18-use-threading
Switch the PPK2_MP class to use threading to fix Issue 18. …
2 parents f05ca67 + 4f9c423 commit 95b893e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/ppk2_api/ppk2_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import logging
1111
import os
1212
import queue
13-
import multiprocessing
13+
import threading
1414

1515
class PPK2_Command():
1616
"""Serial command opcodes"""
@@ -358,9 +358,9 @@ def get_samples(self, buf):
358358
return samples # return list of samples, handle those lists in PPK2 API wrapper
359359

360360

361-
class PPK_Fetch(multiprocessing.Process):
361+
class PPK_Fetch(threading.Thread):
362362
'''
363-
Background process for polling the data in multiprocessing variant
363+
Background process for polling the data in multi-threaded variant
364364
'''
365365
def __init__(self, ppk2, quit_evt, buffer_len_s=10, buffer_chunk_s=0.5):
366366
super().__init__()
@@ -380,7 +380,7 @@ def __init__(self, ppk2, quit_evt, buffer_len_s=10, buffer_chunk_s=0.5):
380380
if self._buffer_chunk % 4 != 0:
381381
self._buffer_chunk = (self._buffer_chunk // 4) * 4
382382

383-
self._buffer_q = multiprocessing.Queue()
383+
self._buffer_q = queue.Queue()
384384

385385
def run(self):
386386
s = 0
@@ -444,7 +444,7 @@ def __init__(self, port, buffer_max_size_seconds=10, buffer_chunk_seconds=0.1):
444444
super().__init__(port)
445445

446446
self._fetcher = None
447-
self._quit_evt = multiprocessing.Event()
447+
self._quit_evt = threading.Event()
448448
self._buffer_max_size_seconds = buffer_max_size_seconds
449449
self._buffer_chunk_seconds = buffer_chunk_seconds
450450

0 commit comments

Comments
 (0)