mirror of
https://gitee.com/openharmony/third_party_libnl
synced 2024-12-04 09:13:33 +00:00
use Callback object constructing Socket
Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
This commit is contained in:
parent
86207d47ab
commit
2d55872fb1
@ -184,10 +184,12 @@ class Socket(object):
|
||||
"""Netlink socket"""
|
||||
|
||||
def __init__(self, cb=None):
|
||||
if cb is None:
|
||||
if isinstance(cb, Callback):
|
||||
self._sock = capi.nl_socket_alloc_cb(cb._cb)
|
||||
elif cb == None:
|
||||
self._sock = capi.nl_socket_alloc()
|
||||
else:
|
||||
self._sock = capi.nl_socket_alloc_cb(cb)
|
||||
raise Exception('\'cb\' parameter has wrong type')
|
||||
|
||||
if self._sock is None:
|
||||
raise Exception('NULL pointer returned while allocating socket')
|
||||
|
Loading…
Reference in New Issue
Block a user