code: def readwrite(obj, flags):
      try:
          if flags & select.POLLIN:
              obj.handle_read_event()
          if flags & select.POLLOUT:
              obj.handle_write_event()
          if flags & select.POLLPRI:
              obj.handle_expt_event()
          if flags & (
              select.POLLHUP | select.POLLERR | select.POLLNVAL
          ):
              obj.handle_close()
      except OSError as e:
          if e.errno not in _DISCONNECTED:
              obj.handle_error()
          else:
              obj.handle_close()
      except _reraised_exceptions:
          raise
      except:
          obj.handle_error()
  
imports: import select
  import socket
  import sys
  import time
  import warnings
  import os
  from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, ENOTCONN, ESHUTDOWN, EISCONN, EBADF, ECONNABORTED, EPIPE, EAGAIN, errorcode
label_desc: Use image node_id 5 for calling a global function with example usage: readwrite(obj, flags) without return types