Hello dlypka, I was investigating this, but after reading the docs I'm a bit confused:
- To use the scheduler in a module what should i do? Create a scheduler.py model and pass the scheduler created in the model to the function in my module as I do with my db? - Can I start and stop the task whenever I want? It seems that I have to insert the task in my db but I don't now when this task will be called because it depend on a certain event and maybe it never happens or it happens 500 times an hour. Thank you very much! On Wednesday, July 9, 2014 2:30:43 AM UTC+2, dlypka wrote: > > Perhaps the Scheduler can help. > > On Saturday, July 5, 2014 11:47:39 AM UTC-5, Wonton wrote: >> >> Hello! >> >> As I commented in other post ( >> https://groups.google.com/forum/#!topic/web2py/ZbEndj2H-fk) I have >> problems using APNSWrapper feedback service sending push notifications. >> >> While I wait for an answer I've thought a possible solution to my >> problem. This solution consists in: >> 1. I'm going to send push notifications to a series of device tokens. >> 2. For the current device token I mark it as "wrong" in the database. >> 3. I send the push notifications. >> 4.1. If the token is wrong the push notification is not sent and >> APNSWrapper fails and the loop of tokens is broken. >> 4.2. If the token is right the push notification is sent. >> 5. I mark that token as "right" in the database. >> >> This way I can check the database and remove all tokens marked with >> "wrong". >> >> The problem is that I'm executing this loop not in the main thread and >> I'm having lots of problems: crashes, error for database connection closed, >> etc... >> >> This is my code: >> >> ifcPushnotifications.py (is a module) >> push_thread = threading.Thread(target=__sendPushToUsersInBackground, args >> =(users, db)) >> push_thread.start() >> >> def __sendPushToUsersInBackground(users, db): >> wrapper = APNSNotificationWrapper('mycert.pem', False) >> for user in users: >> _tokenRow = db(db.push_notifs_table.userId == user['id']) >> _tokenRow.update(status='wrong') >> __sendPushToUser(user) >> _tokenRow.update(status='right') >> >> >> If user's token is wrong __sendPushToUser fails and the loop leaves its >> execution, so in the database it should be 'wrong'. >> >> My problem is that all 3 lines related to database (2 updates and the >> query) fail randomly, sometimes crashes, sometimes returns an error of >> closed database and do nothing, etc... >> >> So, how could I use my database inside a thread so I can avoid this >> errors? >> >> Thank you very much and kind regards! >> > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.