SymbiSoft / android-python27

Automatically exported from code.google.com/p/android-python27
0 stars 0 forks source link

How to stop Python Script Service ? #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Is there a way to stop the Python Script Service?

The Python Script Service just keep running in background after my python 
script finished.

Original issue reported on code.google.com by mike...@gmail.com on 5 Jun 2012 at 12:17

GoogleCodeExporter commented 8 years ago
Try the new option IS_FOREGROUND_SERVICE set to false in GlobalConstants.java: 
see https://code.google.com/p/android-python27/source/detail?r=d88a6707f13d

Original comment by anthony....@gmail.com on 6 Jun 2012 at 6:05

GoogleCodeExporter commented 8 years ago
Great! Thanks!!!

Original comment by mike...@gmail.com on 6 Jun 2012 at 2:51

GoogleCodeExporter commented 8 years ago
The script service keeps on running no matter what I change 
"IS_FOREGROUND_SERVICE" to. Any ideas?

Original comment by andy.e.r...@gmail.com on 7 Oct 2012 at 5:06

GoogleCodeExporter commented 8 years ago
This should be fixed see: 
http://code.google.com/p/android-python27/issues/detail?id=7

I check with ps that the process died when the script ends.

Original comment by anthony....@gmail.com on 7 Oct 2012 at 5:19

GoogleCodeExporter commented 8 years ago
When I run your test script with "IS_FOREGROUND_SERVICE" set to false, 
everything is fine. However when I run my script then the service keeps on 
running after my script exits. My script does start some sub-processes, a 
bottle server to be precise, but all of these are terminated before my script 
exits. My script also works when packaged with the script-for-andriod-template 
taken from sl4a.

I intend to do some more experimentation to see if there is something wrong 
with my app. Maybe I'm not managing my sub-processes correctly or something.

One last thing, I'd like to take the opportunity to thank you for your hard 
work.

Original comment by andy.e.r...@gmail.com on 7 Oct 2012 at 7:40

GoogleCodeExporter commented 8 years ago
Could you attach a minimal script reproducing the problem ?

Original comment by anthony....@gmail.com on 8 Oct 2012 at 5:03

GoogleCodeExporter commented 8 years ago
Yes I can because I just managed to recreate the problem with a simple example. 
I can attach the "my_python_project.zip" file or the entire eclipse project I 
use for testing. Which do you prefer? 

Original comment by andy.e.r...@gmail.com on 8 Oct 2012 at 7:15

GoogleCodeExporter commented 8 years ago
Just the zip is fine.

Original comment by anthony....@gmail.com on 8 Oct 2012 at 7:21

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Here is the zip file as requested. The script does the following things:

    1) creates a bottle server running in the background
    2) starts a browser to read the start page
    3) when you close the browser, renders a button so you can stop the bottle server
    4) exits

The python process exits but "com.android.python27" does not. If I don't kill 
the process my script is started at regular intervals.

Original comment by andy.e.r...@gmail.com on 8 Oct 2012 at 7:00

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
When I click the button to stop the bottle server both com.android.python27 and 
python process exit properly on my device, FWIW I'm using 4.0.4, which android 
version are you using ?

You are using IS_FOREGROUND_SERVICE = false, is that correct ?

So BackgroundScriptService class should be used, you can add some Log in

@Override
public void run() {
  mProxy.shutdown();
  stopSelf(startId);
  killProcess();
  android.os.Process.killProcess(android.os.Process.myPid());

To see in the Logcat if this is called.

Original comment by anthony....@gmail.com on 8 Oct 2012 at 7:15

GoogleCodeExporter commented 8 years ago
Yes, I'm using IS_FOREGROUND_SERVICE = false and I'm also using android 4.0.4. 
Its getting late here in Poland so I'll check the logs tomorrow. Is it possible 
that there is something wrong with the way I'm building my applications?

Original comment by andy.e.r...@gmail.com on 8 Oct 2012 at 7:51

GoogleCodeExporter commented 8 years ago
Attached my test APK.

Original comment by anthony....@gmail.com on 8 Oct 2012 at 8:12

Attachments:

GoogleCodeExporter commented 8 years ago
Your app works fine for me too. All processes exited normally. Any chance you 
could send me your eclipse project so that I can compare it with mine and also 
see what happens when I build an apk with it. 

The problem is obviously at my end. I downloaded the repository just a few days 
ago and I'm sure the project I'm using is based on that download. I'll redo 
everything from scratch and see what happens.

Thanks a lot for your help because I now know where the problem lies.

Original comment by andy.e.r...@gmail.com on 8 Oct 2012 at 8:39

GoogleCodeExporter commented 8 years ago
I just cleaned out all my python projects and downloaded the repository again. 
Now everything works fine for me too. Sorry about that, I must have mixed up my 
projects somehow. I guess I owe you a beer!

Original comment by andy.e.r...@gmail.com on 8 Oct 2012 at 8:59

GoogleCodeExporter commented 8 years ago
Glad that's working now. I would bet for an Eclipse/ADT bug, I hit already so 
much of them.

Original comment by anthony....@gmail.com on 8 Oct 2012 at 9:01