2

After reading on appFog website that I could use APScheduler to make a python background worker, I gave it a try. I tried to push a simple python standalone application with a requirements.txt file (created with pip freeze) which contains the following lines:

APScheduler==2.0.3
MySQL-python==1.2.4b5

But when pushing it to appFog I got the following error:

====> /logs/stderr.log <====
Traceback (most recent call last):
  File "testConnectionDB.py", line 3, in <module>
    from apscheduler.scheduler import Scheduler
ImportError: No module named apscheduler.scheduler

So I guessed the requirements.txt file was not read. The appFog support confirmed that it is indeed not supported yet for standalone apps, i.e. python standalone apps cannot import libraries on appfog, thus their use is very limited.

So I was wondering if someone already had this experience and if someone had found a workaround. I would prefer not do it in ruby or switch to another platform. Is there a way to do this with a regular python or django-python app?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
RockridgeKid
  • 145
  • 3
  • 11

2 Answers2

2

Have you tried launching it within a non-standalone app (such as adding a web interface like CherryPy). That should allow you to compile the requirements.txt and get you out of the standalone app issue.

The above is how I get around the limitation in Ruby apps anyway :)

Rich H.
  • 154
  • 2
  • Thanks for the tip. How would you launch the standalone app in the background? – RockridgeKid Nov 20 '12 at 06:53
  • 1
    Using the web facing interface actually. The web accessible app piece is just a place holder (no functionality). Specifically modify the command to call the actual background scheduler instead of the webapp (I suggest python flask personally) – Rich H. Nov 20 '12 at 16:49
  • Hi Rich, I have installed a basic flask web app and I was able to call the scheduler in for example `@app.route('/scheduler')`. However, it timed out since APScheduler is not used in that case as a background worker. Did I misunderstand your message about using flask or does it need an additional queuing system? – RockridgeKid Nov 21 '12 at 06:38
0

UPDATE:

I was actually able to solve this without resolving to calling my script from a web app. I think this is a better and a true standalone workaround.

It basically involves packaging your script as an executable and then creating a launcher python script to call the produced binary/executable.

You can read about it in detail at my blog.


I was also having the same problem. I didn't want to work my way around a web app to call my script but It seemed like the best way to go.

I managed to do it with Flask and created a route that would call my background worker script. I didn't use APScheduler, just good old os.system() and it seemed stable enough.

I wrote about it in detail on blog.

cr8ivecodesmith
  • 2,021
  • 5
  • 21
  • 30