MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / close

Method close

src/Connection/Connection.py:606–635  ·  view source on GitHub ↗
(self, reason="Unknown")

Source from the content-addressed store, hash-verified

604
605 # Close connection
606 def close(self, reason="Unknown"):
607 if self.closed:
608 return False # Already closed
609 self.closed = True
610 self.connected = False
611 if self.event_connected:
612 self.event_connected.set(False)
613
614 self.log(
615 "Closing connection: %s, waiting_requests: %s, sites: %s, buff: %s..." %
616 (reason, len(self.waiting_requests), self.sites, self.incomplete_buff_recv)
617 )
618 for request in self.waiting_requests.values(): # Mark pending requests failed
619 request["evt"].set(False)
620 self.waiting_requests = {}
621 self.waiting_streams = {}
622 self.sites = 0
623 self.server.removeConnection(self) # Remove connection from server registry
624 try:
625 if self.sock:
626 self.sock.shutdown(gevent.socket.SHUT_WR)
627 self.sock.close()
628 except Exception as err:
629 if config.debug_socket:
630 self.log("Close error: %s" % err)
631
632 # Little cleanup
633 self.sock = None
634 self.unpacker = None
635 self.event_connected = None

Callers 14

badActionMethod · 0.95
messageLoopMethod · 0.95
setHandshakeMethod · 0.95
handleMessageMethod · 0.95
handleHandshakeMethod · 0.95
sendMethod · 0.95
requestMethod · 0.95
getConnectionMethod · 0.95
connectMethod · 0.45
closeConnectionsMethod · 0.45
checkConnectionsMethod · 0.45

Calls 3

logMethod · 0.95
valuesMethod · 0.80
removeConnectionMethod · 0.80

Tested by

no test coverage detected