Skip to content

Instantly share code, notes, and snippets.

@tailhook
Last active March 14, 2016 00:47
Show Gist options
  • Select an option

  • Save tailhook/c7405fa601cf49fe57e1 to your computer and use it in GitHub Desktop.

Select an option

Save tailhook/c7405fa601cf49fe57e1 to your computer and use it in GitHub Desktop.
dll = ctypes.find_library('libstator.so')
message_parser = CFUNCTYPE(py_object, c_uint64, c_void_p, c_size_t)
@message_parser
def parse_message(sock_id, buf, buf_len):
buf = BytesIO((c_uint8 * buf_len).from_address(buf))
return cbor.load(buf)
while True:
message = dll.stator_wait_message(_parse_message)
proccess(message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment