Commits

Anonymous committed e50fe72

Simplify receive notify code, no need for extra flag.

Remove log statements from actnet

Comments (0)

Files changed (2)

         self._gthread = eventlet.spawn(self._tcp_poller,peername)
         
     def _udp_poller(self):
-        log("UDP poller started for",self._sock,self._actaddr)
         try:
             while True:
                 (data,addr)=self._sock.recvfrom(self._recvmax)
                 try:
                     actobj = self._actaddr._actor
                 except (actor.DeadActor, actor.Killed):
-                    log("UDP poller exiting since owner is dead")
                     break
                 msg = {'actnet':UDP,'host':host,'port':port,'data':data}
                 actobj._cast(msg,as_json=False)
                     self._active = False
                     break
         except eventlet.greenlet.GreenletExit:
-            log("UDP poller killed")
+            pass
             
     def _tcp_poller(self,peername):
-        log("TCP poller started for",self._sock,self._actaddr)
         host,port = peername[:2]
         try:
             done = False
                 try:
                     actobj = self._actaddr._actor
                 except (actor.DeadActor, actor.Killed):
-                    log("UDP poller exiting since owner is dead")
                     break
                 if error is None:
                     if len(data)!=0:
                     self._active = False
                     break
         except eventlet.greenlet.GreenletExit:
-            log("TCP poller killed")
-            
+            pass
 
 
 def _sockfam(s):
     simply call receive with no patterns.
     """
     _wevent = None
-    _already_notified = False
     _mailbox = lazy_property('_p_mailbox', lambda self: [])
     _links = lazy_property('_p_links', lambda self: [])
     _exit_links = lazy_property('_p_exit_links', lambda self: [])
         Otherwise, select the next message.
         """
         timeout = kw.get('timeout',None)
-            
         if timeout == 0 :
             if not patterns:
                 if self._mailbox:
                 else:
                     return None,None
             return self._match_patterns(patterns)
-
         if timeout is not None:
             timer = eventlet.Timeout(kw['timeout'], ReceiveTimeout)
         else:
             timer = None
-
         try:
-
             while True:
-
                 if patterns:
                     matched_pat, matched_msg = self._match_patterns(patterns)
                 elif self._mailbox:
                     matched_pat, matched_msg = {object:object},self._mailbox.pop(0)
                 else:
                     matched_pat = None
-
                 if matched_pat is not None:
                     if timer:
                         timer.cancel()
                     return matched_pat,matched_msg
-
                 self._wevent = event.Event()
-                self._already_notified = False
                 try:
-                    # wait until at least one message is sent
-                    # or timeout occurs
+                    # wait until at least one message or timeout
                     self._wevent.wait()
                 finally:
                     self._wevent = None
-                    self._already_notified = False
-                    
-
         except ReceiveTimeout:
             return (None,None)
 
             link.cast({'address': self.address, 'exit': result})
         self.all_actors.pop(self.actor_id)
 
-    def _cast(self, message):
+    def _cast(self, message, as_json=True):
         """For internal use.
         
         Address uses this to insert a message into this Actor's mailbox.
         """
-        self._mailbox.append(json.loads(message, object_hook=generate_custom))
-        if self._wevent and not self._already_notified:
-            self._already_notified = True
+        if as_json:
+            message = json.loads(message, object_hook=generate_custom)
+        self._mailbox.append(message)
+        if self._wevent and not self._wevent.has_result():
             self._wevent.send(None)
 
+
 class Server(Actor):
     """An actor which responds to the call protocol by looking for the
     specified method and calling it.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.