Skip to content

Commit c293849

Browse files
committed
Coerce port to uint16_t
As this is the type expected by the C level functions that we call later when using `port`, go ahead and coerce it to `uint16_t` in advance. This should make it easier to release the GIL later on.
1 parent 5cbc5e2 commit c293849

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ucp/_libs/core.pyx

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import os
66
import asyncio
77
import weakref
88
from functools import partial
9-
from libc.stdint cimport uint64_t, uintptr_t
9+
from libc.stdint cimport uint16_t, uint64_t, uintptr_t
1010
import uuid
1111
import socket
1212
import logging
@@ -401,7 +401,8 @@ cdef class ApplicationContext:
401401
if self.blocking_progress_mode:
402402
close(self.epoll_fd)
403403

404-
def create_listener(self, callback_func, port, guarantee_msg_order):
404+
def create_listener(self, callback_func,
405+
port, guarantee_msg_order):
405406
from ..public_api import Listener
406407
self.continuous_ucx_progress()
407408
if port in (None, 0):
@@ -423,11 +424,12 @@ cdef class ApplicationContext:
423424
Py_INCREF(callback_func)
424425

425426
cdef ucp_listener_params_t params
427+
cdef uint16_t port_int = port
426428
cdef ucp_listener_accept_callback_t _listener_cb
427429
with nogil:
428430
_listener_cb = <ucp_listener_accept_callback_t>_listener_callback
429431
if c_util_get_ucp_listener_params(&params,
430-
port,
432+
port_int,
431433
_listener_cb,
432434
<void*> &ret._cb_args):
433435
with gil:

0 commit comments

Comments
 (0)