Skip to content

Commit

Permalink
Coerce port to uint16_t
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jakirkham committed Jan 14, 2020
1 parent 5cbc5e2 commit c293849
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ucp/_libs/core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import os
import asyncio
import weakref
from functools import partial
from libc.stdint cimport uint64_t, uintptr_t
from libc.stdint cimport uint16_t, uint64_t, uintptr_t
import uuid
import socket
import logging
Expand Down Expand Up @@ -401,7 +401,8 @@ cdef class ApplicationContext:
if self.blocking_progress_mode:
close(self.epoll_fd)

def create_listener(self, callback_func, port, guarantee_msg_order):
def create_listener(self, callback_func,
port, guarantee_msg_order):
from ..public_api import Listener
self.continuous_ucx_progress()
if port in (None, 0):
Expand All @@ -423,11 +424,12 @@ cdef class ApplicationContext:
Py_INCREF(callback_func)

cdef ucp_listener_params_t params
cdef uint16_t port_int = port
cdef ucp_listener_accept_callback_t _listener_cb
with nogil:
_listener_cb = <ucp_listener_accept_callback_t>_listener_callback
if c_util_get_ucp_listener_params(&params,
port,
port_int,
_listener_cb,
<void*> &ret._cb_args):
with gil:
Expand Down

0 comments on commit c293849

Please sign in to comment.