Hi, I am using scheduler in my application which will periodically sends mail to the user, but when i start worker on command prompt using web2py.py -K MyApp, its giving follwoing error on command prompt:
D:\web2py2.1.1\web2py>web2py.py -K MyApp No handlers could be found for logger "web2py" web2py Web Framework Created by Massimo Di Pierro, Copyright 2007-2012 Version 2.1.1 (2012-10-15 12:44:40) stable Database drivers available: SQLite(sqlite3), MySQL(pymysql), PostgreSQL( pg8000), IMAP(imaplib) starting single-scheduler for "MyApp"... Traceback (most recent call last): File "D:\web2py2.1.1\web2py\gluon\restricted.py", line 209, in restricted exec ccode in environment File "applications\MyApp\models\db.py", line 48, in <module> import requests File "D:\web2py2.1.1\web2py\gluon\custom_import.py", line 70, incustom_import er raise ImportError, 'Cannot import module %s' % str(e) ImportError: Cannot import module 'requests' Below are the code of scheduler and function: db.scheduler_task.validate_and_insert( function_name='send_mail', args='[]', repeats = 0, # run indifinitely period = 60, # every 2 mins timeout = 120, # should take less than 120 seconds ) def send_mail(): message = 'Hello' post_message(message) from mailgun import * import requests def post_message(testmessage): r = requests.post(("https://api.mailgun.net/v2/amit.mailgun.org/" "messages"), auth=("api", "key-3k7c-lqsdfssssnphzid4rbmnr9vp913y9q94"), data={ "from": "Excited User <a...@amit.mailgun.org>", "to": ["amit.khaw...@gmail.com"], "subject": "Update", "text": str(testmessage) } ) return r And when i keep statement import requests inside post_message() function then the error is not displaying on the command prompt , it seems like worker has started successfully but when I checked in verified in database the task status is showing as FAILED and when I see the stack trace ,its displaying the same error as above. Can anyone guide me to solve this issue? --