Skip to content

Commit eeba635

Browse files
committed
added free threading comment
1 parent 58b823f commit eeba635

4 files changed

Lines changed: 19 additions & 16 deletions

File tree

python_bladerf/pybladerf_tools/pybladerf_transfer.pyx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
# SOFTWARE.
2222

2323
# distutils: language = c++
24-
# cython: language_level=3str
24+
# cython: language_level = 3str
25+
# cython: freethreading_compatible = True
2526
from libc.stdint cimport uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t
2627
from python_bladerf.pylibbladerf cimport pybladerf as c_pybladerf
27-
from python_bladerf.pylibbladerf.ctime cimport get_time
2828
from python_bladerf import pybladerf
2929
from libcpp cimport bool as c_bool
3030
from libcpp.atomic cimport atomic
@@ -110,7 +110,7 @@ cpdef void rx_process(c_pybladerf.PyBladerfDevice device,
110110
uintptr_t transfer_status_ptr,
111111
uint8_t channel,
112112
uint8_t oversample,
113-
object notify_finished,
113+
object close_ready,
114114
object rx_buffer,
115115
object file,
116116
int num_samples):
@@ -150,7 +150,7 @@ cpdef void rx_process(c_pybladerf.PyBladerfDevice device,
150150
if num_samples == 0:
151151
working_sdrs[device_id].store(0)
152152

153-
notify_finished.set()
153+
close_ready.set()
154154

155155

156156
@cython.boundscheck(False)
@@ -161,7 +161,7 @@ cpdef void tx_process(c_pybladerf.PyBladerfDevice device,
161161
uint8_t channel,
162162
uint8_t oversample,
163163
uint8_t repeat_tx,
164-
object notify_finished,
164+
object close_ready,
165165
object tx_buffer,
166166
object file,
167167
int num_samples):
@@ -284,7 +284,7 @@ cpdef void tx_process(c_pybladerf.PyBladerfDevice device,
284284
transfer_status.stream_power.fetch_add(np.sum(buffer[:writed * 2].astype(np.int32) ** 2))
285285
continue
286286

287-
notify_finished.set()
287+
close_ready.set()
288288

289289

290290
def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_000, baseband_filter_bandwidth: int | None = None,
@@ -384,7 +384,7 @@ def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_0
384384

385385
rx_file = open(rx_filename, 'wb') if rx_filename not in ('-', None) else (sys.stdout.buffer if rx_filename == '-' else None)
386386
tx_file = open(tx_filename, 'rb') if tx_filename not in ('-', None) else (sys.stdin.buffer if tx_filename == '-' else None)
387-
notify_finished = threading.Event()
387+
close_ready = threading.Event()
388388

389389
cdef TransferStatus transfer_status
390390
if rx_buffer is not None or rx_filename is not None:
@@ -403,7 +403,7 @@ def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_0
403403
<uintptr_t> &transfer_status,
404404
formated_channel,
405405
1 if oversample else 0,
406-
notify_finished,
406+
close_ready,
407407
rx_buffer,
408408
rx_file,
409409
num_samples if num_samples else -1
@@ -427,7 +427,7 @@ def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_0
427427
formated_channel,
428428
1 if oversample else 0,
429429
1 if repeat_tx else 0,
430-
notify_finished,
430+
close_ready,
431431
tx_buffer,
432432
tx_file,
433433
num_samples if num_samples else -1
@@ -440,8 +440,8 @@ def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_0
440440
if num_samples and print_to_console:
441441
sys.stderr.write(f'samples_to_xfer {num_samples}/{num_samples / (5e5 if oversample else 25e4):.3f} MB\n')
442442

443-
cdef double time_start = get_time()
444-
cdef double time_prev = get_time()
443+
cdef double time_start = time.time()
444+
cdef double time_prev = time.time()
445445
cdef double time_difference = 0
446446
cdef uint64_t stream_power = 0
447447
cdef double dB_full_scale = 0
@@ -452,7 +452,7 @@ def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_0
452452

453453
while working_sdrs[device_id].load():
454454
time.sleep(0.05)
455-
time_now = get_time()
455+
time_now = time.time()
456456
time_difference = time_now - time_prev
457457
if time_difference >= 1.0:
458458
if print_to_console:
@@ -483,7 +483,7 @@ def pybladerf_transfer(frequency: int | None = None, sample_rate: int = 10_000_0
483483

484484
working_sdrs[device_id].store(0)
485485
sdr_ids.pop(device.serialno, None)
486-
notify_finished.wait()
486+
close_ready.wait()
487487

488488
trigger.role = pybladerf.pybladerf_trigger_role.PYBLADERF_TRIGGER_ROLE_DISABLED
489489
device.pybladerf_trigger_arm(trigger, False)

python_bladerf/pylibbladerf/cbladerf.pxd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# SOFTWARE.
2222

2323
# distutils: language = c++
24-
# cython: language_level=3str
24+
# cython: language_level = 3str
25+
# cython: freethreading_compatible = True
2526
from libcpp cimport bool as c_bool
2627
from libc.stdint cimport *
2728

python_bladerf/pylibbladerf/pybladerf.pxd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# SOFTWARE.
2222

2323
# distutils: language = c++
24-
# cython: language_level=3str
24+
# cython: language_level = 3str
25+
# cython: freethreading_compatible = True
2526
from libcpp cimport bool as c_bool
2627
from . cimport cbladerf
2728

python_bladerf/pylibbladerf/pybladerf.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
# SOFTWARE.
2222

2323
# distutils: language = c++
24-
# cython: language_level=3str
24+
# cython: language_level = 3str
25+
# cython: freethreading_compatible = True
2526
from python_bladerf import __version__
2627
from libc.stdint cimport uint8_t, int16_t, uint16_t, int32_t, uint32_t, uint64_t, uintptr_t
2728
from libc.string cimport memcpy, memset, strncpy

0 commit comments

Comments
 (0)