Share

PyS60

Tracker: Bugs

6 Hung active objects - ID: 1550413
Last Update: Comment added ( jplauril )

Hi,
i've experienced different situations when Python stops
responding when active objects are in use. Here's two
example scripts that I can reproduce on pys60 1.3.1 on
N70. The first one hangs in sound.Sound.play() and the
second one in select.select(), both when e32.ao_sleep()
has been called simultaneously.

First example:
1. run aolocktest.py on phone
2. press joystick => nokia tune will play
3. wait until title says "unlocked"
4. press joystick => nokia tune again
5. press joystick again while title says "locked"
6. title changes to "play()" and Python hangs

Second example:
1. run sleepbug.py on phone
2. press joystick => text changes to "pressed..."
3. wait until title says "unlocked"
4. press joystick => text changes again
5. press joystick again while title says "locked"
6. text changes to "waiting..." and Python hangs

Jarno


Jarno Seppänen ( jams ) - 2006-09-01 09:41

6

Closed

Rejected

Jukka Laurila

e32

v1.3.1

Public


Comment ( 1 )

Date: 2007-06-12 18:47
Sender: jplaurilProject Admin


Both of these are instances of the same fundamental problem, of doing too
much in callbacks.

An important thing to realize is how callbacks from active objects are
handled. Callbacks are not executed in a new thread or in any kind of
separate execution context. Whenever Python waits for a long-running
operation to complete, it starts an active scheduler loop. If requests from
some active objects complete during this wait, the corresponding callbacks
that were triggered will _run to completion_ before processing can continue
after the scheduler loop.

In your code you have callbacks that run for a very long time (for example
in sleepbug.py the use method) and your callbacks contain long-running
operations that start their own schedulers (for example in sleepbug.py you
have ao_sleep and select calls). When a callback is triggered during this
time, you will every time get yet another level of scheduler nesting, and
you will never get out of these loops.

There is really no solution to this other than a coding convention that
keeps the complexity of callbacks at a minimum. In the future we may
consider taking into use some checks that would enforce this simplicity, if
we can only figure out how to do it without crippling legitimate uses of
nested schedulers.

It's unfortunate that the syntax misleads people into thinking the system
is more powerful than it really is.

Working as designed, unfortunately.



Attached Files ( 2 )

Filename Description Download
aolocktest.py Download
sleepbug.py Download

Changes ( 9 )

Field Old Value Date By
status_id Open 2007-06-12 18:47 jplauril
close_date - 2007-06-12 18:47 jplauril
assigned_to vbartoni 2007-06-12 18:47 jplauril
resolution_id None 2007-06-12 18:47 jplauril
priority 5 2007-02-19 17:44 jplauril
assigned_to nobody 2007-02-19 16:29 jplauril
category_id None 2007-02-19 16:29 jplauril
File Added 191572: sleepbug.py 2006-09-01 09:41 jams
File Added 191571: aolocktest.py 2006-09-01 09:41 jams