Pysage does not have any external dependencies. It works with Python
2.6+ and according to the guide, you should be able to copy it to the
"extra/python" directory.
John
> --
> You received this message because you are subscribed to the Google Groups "pysage" group.
> To post to this group, send email to pys...@googlegroups.com.
> To unsubscribe from this group, send email to pysage+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pysage?hl=en.
>
>
I'm not sure how this is related to user accounts. But the problem is here:
File "/mnt/sdcard/com.googlecode.pythonforandroid/extras/python/
pysage/transport.py", line 265, in listen
self._connection = processing.connection.Listener()
Try doing these 2 lines in the environment:
>>> from multiprocessing import connection
>>> l = connection.Listener()
If this fails, you can try using a different socket family, like:
>>> from multiprocessing import connection
>>> l = connection.Listener(family='AF_INET')
Or maybe try giving it an address. Let me know how this turns out.
BTW, what are you using the group for? I'm considering adding a
feature to pysage which would optionally turn message handlers to
coroutines. This allows you to "yield" without forking an entirely
different process.
John
Pysage replies on multiprocessing for its IPC. I see two options
depending on your performance needs:
1. do everything in one process in the pysage main loop. You should
still be able to pool using "select" very quickly. This is the
"yield" feature I was talking about earlier. Sample code below:
class HardwareMonitor(Actor):
def handle_StartPolling(self, msg):
while True:
io = select(...)
if io:
handle_io()
else:
yield
The "yield" here makes this handler method a "coroutine" or
"generator" and as long as it doesn't exist, pysage would include it
in the main loop. If your "handle_io" method does not block, you'll
be just fine.
2. in the case that some parts of this DOES block. You may elect to
run it in a thread.
Here's a sample decorator you can use with your "handle_io" method:
def run_in_thread(fn):
@functools.wraps(fn)
def wrapper(*args, **kws):
t = threading.Thread(target=fn, args=args, kwargs=kws)
t.start()
return wrapper
And you would use it like:
@run_in_thread
def handle_io():
something_that_takes_a_while()
Does that help?
John
Just to be clear. Option #1 still needs to be implemented. But if
you want, you can read up on python generators to get a better
understanding.
John
class HardwareMonitor(Actor):
def handle_StartPolling(self, msg):
while True:
io = select(...)
if io:
handle_io()
yield
In short, decorator is a function that wraps another function. Link
below will explain much better than I do:
http://www.python.org/dev/peps/pep-0318/
The "@" sign makes the code clearer. As you are exploring this
option, please provide sample code when you've reached a good point of
your use case. Keep in mind, you do need to ensure that the code ran
in the thread will be thread-safe. This is the trade off compared to
option #1.
John
if not cq.is_done():for cqitem in cq.get_next_collected(): #harvestmgr.queue_message_to_group( mgr.PYSAGE_MAIN_GROUP, MyMessage( cqitem.args, cqitem.get_return()))
--