Skip to content

Instantly share code, notes, and snippets.

@cwebber
Created July 21, 2013 15:48
Show Gist options
  • Save cwebber/6048931 to your computer and use it in GitHub Desktop.
Save cwebber/6048931 to your computer and use it in GitHub Desktop.
debugging data on actors
diff --git a/xudd/hive.py b/xudd/hive.py
index e9bc0d0..3987aed 100644
--- a/xudd/hive.py
+++ b/xudd/hive.py
@@ -67,6 +67,7 @@ class HiveWorker(Thread):
# We didn't do anything this round, oh well
return False
+ print("%s got actor %s" % (self, actor))
# Process messages from this actor
messages_processed = 0
while self.max_messages is None \
@@ -85,6 +86,7 @@ class HiveWorker(Thread):
actor.handle_message(message)
messages_processed += 1
+ print("Is %s in queue already?: %s" % (actor, actor in self.hive.actor_queue.queue))
# Request checking if actor should be requeued with hive
self.hive.request_possibly_requeue_actor(actor)
@@ -105,6 +107,7 @@ class Hive(Thread):
# Actor queue
self.__actor_queue = Queue()
+ self.actor_queue = self.__actor_queue
self.num_workers = num_workers
self.__workers = []
@@ -224,6 +227,7 @@ class Hive(Thread):
# Should we requeue?
if not actor.message_queue.queue.empty():
# Looks like so!
+ print("requeueing %s" % actor)
self.queue_actor(actor)
elif action_type == "queue_message":
@cwebber
Copy link
Author

cwebber commented Jul 21, 2013

The results:

<HiveWorker(Thread-2, started 140265666098944)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
<HiveWorker(Thread-6, started 140265562035968)> got actor <main.DepartmentChair object at 0x7f922534f190>
<HiveWorker(Thread-5, started 140265570428672)> got actor <main.DepartmentChair object at 0x7f922534f190>
<HiveWorker(Thread-2, started 140265666098944)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
<HiveWorker(Thread-6, started 140265562035968)> got actor <main.DepartmentChair object at 0x7f922534f190>
<HiveWorker(Thread-5, started 140265570428672)> got actor <main.DepartmentChair object at 0x7f922534f190>
<HiveWorker(Thread-2, started 140265666098944)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
<HiveWorker(Thread-6, started 140265562035968)> got actor <main.DepartmentChair object at 0x7f922534f190>
<HiveWorker(Thread-5, started 140265570428672)> got actor <main.DepartmentChair object at 0x7f922534f190>
<HiveWorker(Thread-2, started 140265666098944)> got actor <main.Professor object at 0x7f9224318710>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.Professor object at 0x7f9224318710> in queue already?: False
<HiveWorker(Thread-6, started 140265562035968)> got actor <main.DepartmentChair object at 0x7f922534f190>
requeueing <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
67057951-8e96-4796-8bca-668e139bb259 experiment is done
Last experiment message (ce2aae37-9021-49c3-9351-ad8647efc7c8:2198) received, shutting down
66efb61c-98bd-474e-b767-6ce1b14de184 experiment is done
<HiveWorker(Thread-2, started 140265666098944)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Last experiment message (ce2aae37-9021-49c3-9351-ad8647efc7c8:2200) received, shutting down
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
<HiveWorker(Thread-3, started 140265657706240)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
<HiveWorker(Thread-5, started 140265570428672)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
<HiveWorker(Thread-4, started 140265578821376)> got actor <main.DepartmentChair object at 0x7f922534f190>
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True
Is <main.DepartmentChair object at 0x7f922534f190> in queue already?: True

@cwebber
Copy link
Author

cwebber commented Jul 21, 2013

Curiously, the above is in python 3. In python 2, the "in queue already" problem doesn't appear to be so:

Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False
Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False
Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False
<HiveWorker(Thread-6, started 139958060828416)> got actor <__main__.DepartmentChair object at 0x7f4a8d269310>
42b56fc7-106e-42d0-8026-534e13ee9328 experiment is done
<HiveWorker(Thread-2, started 139958163937024)> got actor <__main__.DepartmentChair object at 0x7f4a8d269310>
641bf397-f1cd-4f56-8b3b-2412f9f06aa8 experiment is done
Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False
Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False
<HiveWorker(Thread-5, started 139958069221120)> got actor <__main__.DepartmentChair object at 0x7f4a8d269310>
7748640a-65d9-4f19-95f3-10368468a9a7 experiment is done
<HiveWorker(Thread-2, started 139958163937024)> got actor <__main__.DepartmentChair object at 0x7f4a8d269310>
85724120-9703-4beb-806c-4d4e50b85d4d experiment is done
Last experiment message (f3d7eeff-5fb1-408b-85f9-594843d5b182:2200) received, shutting down
Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False
Is <__main__.DepartmentChair object at 0x7f4a8d269310> in queue already?: False

note that there's no block=True in this verison.
The python 2 version doesn't seem to be hitting the same bug!

However, something still seems wrong: it doesn't make sense that the DepartmentChair (of which there is only one) would be being wrapped up twice after the "shutting down" message, unless this is some threading goofiness in python and it's just printing out of order. At the time that the last experiment is received, that message should only appear one more time and then it should be over and done with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment