Can you share some code so we ret reproduce it and fix it? We do not need 
all the code. Just a minimalist example that causes the same problem.

On Friday, 5 October 2012 16:24:11 UTC-5, Adi wrote:
>
> yes, i just confirmed by running in parallel 9/13 and 10/5
>
> results:
> 9/13 partially works (will execute task, mark it as "COMPLETED" in 
> scheduler_tasks, but will mark it as "FAILED" in scheduler_run and won't 
> update details in there...
> 10/5 doesn't work (RuntimeError: Cannot duplicate a Singleton)
>
>
> On Fri, Oct 5, 2012 at 11:59 AM, Massimo Di Pierro 
> <massimo....@gmail.com<javascript:>
> > wrote:
>
>> To summarize:
>> 1) 9/13 version works
>> 2) 10/4 version does not work as you expected
>>
>> Did you try any 10/5 version?
>>
>>
>> On Friday, 5 October 2012 10:21:46 UTC-5, Adi wrote:
>>>
>>>
>>> for what it's worth, just want to let you know that after rolling back 
>>> to "Version 2.0.9 (2012-09-13 23:51:30) stable" tasks are getting 
>>> executed, marked as COMPLETED, but schedule_run is being marked as FAILED w 
>>> bellow specified sys.exit(1). 
>>>
>>> anyway... this is perfect for now, and customers won't suffer :) 
>>>
>>> scheduler and workflow are two crucial things in complex applications 
>>> from my prospective, so big thanks for scheduler, and can't wait to start 
>>> testing workflow once it's in. 
>>>
>>> On Friday, October 5, 2012 9:27:22 AM UTC-4, Adi wrote:
>>>>
>>>>
>>>> Created a new application from admin panel, accessing single mysql db, 
>>>> inserted one task that sends an email and prints a test message. 
>>>>
>>>> Version 2.0.9 (2012-10-04 20:17:03) dev
>>>>
>>>> def test():
>>>>     db.scheduler_task.insert(
>>>>                              status='QUEUED',
>>>>                              application_name='test2',
>>>>                              task_name='send reminder email',
>>>>                              function_name='send_msg',
>>>>                              enabled=True,
>>>>                              start_time = request.now,
>>>>                              next_run_time = request.now+datetime.
>>>> timedelta**(minutes=2),
>>>>                              stop_time = request.now+datetime.timedelta
>>>> **(days=1),
>>>>                              repeats = 1, # run 1 times
>>>>                              period = 120, 
>>>>                              timeout = 60, # should take less than 60 
>>>> seconds
>>>>                              )
>>>>
>>>>
>>>>
>>>> *started scheduler: *
>>>> asm21:web2py209 adnan$ python web2py.py -a pass -K test2 -X
>>>> web2py Web Framework
>>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>>> Version 2.0.9 (2012-10-04 20:17:03) dev
>>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
>>>> PostgreSQL(pg8000), IMAP(imaplib)
>>>> please visit:
>>>>  starting scheduler for "test2"...    http://127.0.0.1:8000
>>>>
>>>> use "kill -SIGTERM 831" to shutdown the web2py server
>>>> Currently running 1 scheduler processes
>>>> Processes started
>>>> ERROR:Rocket.Errors.Port8000:**Socket 127.0.0.1:8000 in use by other 
>>>> process and it won't share.
>>>> WARNING:Rocket.Errors.**Port8000:Listener started when not ready.
>>>> Traceback (most recent call last):
>>>>   File "/Users/adnan/web2py209/gluon/**restricted.py", line 209, in 
>>>> restricted
>>>>     exec ccode in environment
>>>>   File "applications/test2/models/db.**py", line 15, in <module>
>>>>     db = 
>>>> DAL('mysql://crm:password@**localhost:3307/CRM',migrate_**enabled=False, 
>>>> fake_migrate_all=True)
>>>>   File "/Users/adnan/web2py209/gluon/**dal.py", line 6600, in __new__
>>>>     raise RuntimeError, 'Cannot duplicate a Singleton'
>>>> RuntimeError: Cannot duplicate a Singleton
>>>>
>>>>
>>>> *traceback error in the scheduler_run table after task was run (first 
>>>> time):*
>>>> Traceback (most recent call last):
>>>>   File "/opt/web-apps/web2py/gluon/**scheduler.py", line 203, in 
>>>> executor
>>>>     _env = env(a=a,c=c,import_models=**True)
>>>>   File "/opt/web-apps/web2py/gluon/**shell.py", line 127, in env
>>>>     environment = build_environment(request, response, session)
>>>>   File "/opt/web-apps/web2py/gluon/**compileapp.py", line 388, in 
>>>> build_environment
>>>>     t = environment['T'] = translator(request)
>>>>   File "/opt/web-apps/web2py/gluon/**languages.py", line 437, in 
>>>> __init__
>>>>     self.set_current_languages()
>>>>   File "/opt/web-apps/web2py/gluon/**languages.py", line 492, in 
>>>> set_current_languages
>>>>     pl_info = self.get_possible_languages_**info('default')
>>>>   File "/opt/web-apps/web2py/gluon/**languages.py", line 471, in 
>>>> get_possible_languages_info
>>>>     info = read_possible_languages(self.**folder)
>>>>   File "/opt/web-apps/web2py/gluon/**languages.py", line 250, in 
>>>> read_possible_languages
>>>>     lambda: read_possible_languages_aux(**langdir))
>>>>   File "/opt/web-apps/web2py/gluon/**cfs.py", line 40, in getcfs
>>>>     return filter() if callable(filter) else ''
>>>>   File "/opt/web-apps/web2py/gluon/**languages.py", line 250, in 
>>>> <lambda>
>>>>     lambda: read_possible_languages_aux(**langdir))
>>>>   File "/opt/web-apps/web2py/gluon/**languages.py", line 215, in 
>>>> read_possible_languages_aux
>>>>     flist = oslistdir(langdir)
>>>> OSError: [Errno 2] No such file or directory: 
>>>> 'applications/test2/languages'
>>>>
>>>> *traceback error in the scheduler_run table after task was run (second 
>>>> time):*
>>>> Traceback (most recent call last):
>>>>   File "/Users/adnan/web2py209/gluon/**scheduler.py", line 203, in 
>>>> executor
>>>>     _env = env(a=a,c=c,import_models=**True)
>>>>   File "/Users/adnan/web2py209/gluon/**shell.py", line 134, in env
>>>>     sys.exit(1)
>>>> SystemExit: 1
>>>>
>>>> Please let me know if there is anything else I can test to help figure 
>>>> out where exactly is the problem? It's a bit urgent for me to figure this 
>>>> out, or I have to roll back production before weekend starts :(
>>>>
>>>>
>>>>
>>>> On Friday, October 5, 2012 12:00:57 AM UTC-4, Adi wrote:
>>>>>
>>>>> Will run more tests in the morning on a brand new application, since I 
>>>>> can't see anything wrong (connection string duplication) in code right 
>>>>> now. 
>>>>> Unfortunately, can't roll back this functionality now, so will have to 
>>>>> figure it out quickly. Thanks for help Massimo and Niphlod. 
>>>>>
>>>>>
>>>>> On Thu, Oct 4, 2012 at 10:32 PM, Massimo Di Pierro wrote:
>>>>>
>>>>>> No. this should not be a problem. This is only be a problem if any 
>>>>>> two have the same connection string.
>>>>>>
>>>>>>
>>>>>> On Thursday, 4 October 2012 21:10:58 UTC-5, Adi wrote:
>>>>>>
>>>>>>> I'm using 6 connections at the same time, 3 go to different 
>>>>>>> databases on the same server, and 3 to totally different servers. Each 
>>>>>>> connection has a different name
>>>>>>>
>>>>>>> db = DAL('mysql://crm:password@**loca**lhost:3307/CRM',migrate_**
>>>>>>> enable**d=True)
>>>>>>> db_us = DAL('mysql://web_US:password@**l**ocalhost:3307/DataUS',**
>>>>>>> migrate_**enabled=False, fake_migrate_all=True)
>>>>>>> db_ca = DAL('mysql://web_CA:password@**l**ocalhost:3307/DataCA', 
>>>>>>> migrate_enabled=False, fake_migrate_all=True)
>>>>>>> ...
>>>>>>>
>>>>>>> Could something like this be a problem:
>>>>>>> In a scheduler function, based on application that inserted a task, 
>>>>>>> I assign relevant connection to another object to use?
>>>>>>>  
>>>>>>> if application='ca':
>>>>>>>     db_front_end = db_ca 
>>>>>>> elif application='us':
>>>>>>>     db_front_end = db_us
>>>>>>>
>>>>>>> use db_front_end to retrieve data and perform scheduled task
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Oct 4, 2012 at 9:42 PM, Massimo Di Pierro <
>>>>>>> massimo....@gmail.com> wrote:
>>>>>>>
>>>>>>>> This error can arise in two cases:
>>>>>>>> - you are using an a recent trunk version (not the latest) which 
>>>>>>>> has a bug
>>>>>>>> - you are using the latest trunk (no bug) but you have a duplicated 
>>>>>>>> connection in your code:
>>>>>>>>
>>>>>>>> db = DAL(....)
>>>>>>>> db = DAL(....)
>>>>>>>>
>>>>>>>> perhaps in different model files. Previous web2py did not check and 
>>>>>>>> allowed you to have two connections to the same database. We found 
>>>>>>>> this is 
>>>>>>>> often source or errors. The new web2py checks and does not allow you 
>>>>>>>> to do 
>>>>>>>> it. Your would get the error you see.
>>>>>>>>
>>>>>>>>
>>>>>>>> On Thursday, 4 October 2012 14:42:59 UTC-5, Adi wrote:
>>>>>>>>
>>>>>>>>> We promoted latest night build to production, and scheduler 
>>>>>>>>> started failing. At the same time there were some code changes, so 
>>>>>>>>> I'm 
>>>>>>>>> having a hard time tracing the source of the problem.
>>>>>>>>>
>>>>>>>>> Any insights while I'm trying to figure it out?
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> Adi
>>>>>>>>>
>>>>>>>>> db: mysql
>>>>>>>>> redhat linux
>>>>>>>>> w2p: Version 2.0.9 (2012-10-02 03:55:58) dev
>>>>>>>>>
>>>>>>>>> scheduler_run table: traceback field:
>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>   File "/opt/web-apps/web2py/gluon/**sc****heduler.py", line 203, 
>>>>>>>>> in executor
>>>>>>>>>     _env = env(a=a,c=c,import_models=**True****)
>>>>>>>>>   File "/opt/web-apps/web2py/gluon/**sh****ell.py", line 134, in 
>>>>>>>>> env
>>>>>>>>>     sys.exit(1)
>>>>>>>>> SystemExit: 1
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> scheduler log:
>>>>>>>>> /opt/web-apps/web2py/gluon/**dal****.py:6597: DeprecationWarning: 
>>>>>>>>> object.__new__() takes no parameters
>>>>>>>>>   db = super(DAL, cls).__new__(cls, uri, *args, **kwargs)
>>>>>>>>> web2py Web Framework
>>>>>>>>> Created by Massimo Di Pierro, Copyright 2007-2012
>>>>>>>>> Version 2.0.9 (2012-10-02 03:55:58) dev
>>>>>>>>> Database drivers available: SQLite(sqlite3), MySQL(pymysql), 
>>>>>>>>> PostgreSQL(pg8000), IMAP(imaplib)
>>>>>>>>> starting single-scheduler for "crm"...
>>>>>>>>> Traceback (most recent call last):
>>>>>>>>>   File "/opt/web-apps/web2py/gluon/**re****stricted.py", line 
>>>>>>>>> 209, in restricted
>>>>>>>>>     exec ccode in environment
>>>>>>>>>   File "applications/crm/models/db.**py****", line 47, in <module>
>>>>>>>>>     db = DAL('mysql://crm:password@**loca****
>>>>>>>>> lhost:3307/CRM',migrate_**enable****d=False, 
>>>>>>>>> fake_migrate_all=True)
>>>>>>>>>   File "/opt/web-apps/web2py/gluon/**da****l.py", line 6595, in 
>>>>>>>>> __new__
>>>>>>>>>     raise RuntimeError, 'Cannot duplicate a Singleton'
>>>>>>>>> RuntimeError: Cannot duplicate a Singleton
>>>>>>>>>
>>>>>>>>>  -- 
>>>>>>>>  
>>>>>>>>  
>>>>>>>>  
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>  -- 
>>>>>>  
>>>>>>  
>>>>>>  
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>>  -- 
>>  
>>  
>>  
>>
>
>
>
> -- 
>
> Thanks,
> Adnan
>
> video: http://vimeo.com/24653283
>
>
>

-- 



Reply via email to