waitfor it and pylons debugger, WAS: Running a program without waiting for it to finish

2009-01-07 Thread Jules Stevenson

Hi Ian,

 I didn't notice this thread first time around, but you might find
 WaitForIt (http://pythonpaste.org/waitforit/) helpful for cases like
 these; you could write the code as blocking and let WaitForIt deal with
 the long-running aspect.  (Assuming it runs for a long time, but
 eventually finishes -- if you need to interact with it over time you
 should stuff the process object in a module global)

Thanks, this does indeed look like just the ticket. However I'm struggling
to get this to work with Pylons correctly, specifically it seems to
interfere with the debugger in the way that I have it set up [which is
probably wrong].

To set it up I came across a post
(http://www.mail-archive.com/paste-us...@pythonpaste.org/msg00213.html) on
the paste mailing list which contained the following info:

---
so then I tried to
use waitforit with pylons, so I made a new pylons app and added this to
my test.ini file:

[app:main]
use = config:development.ini
filter-with = slow

[filter:slow]
use=egg:waitforit
time_limit=2
poll_time=1
---

I don't think I even use test.ini, so I modded my development.ini file to
look like this:

snip

[app:main]
use = egg:ark
full_stack = true
cache_dir = %(here)s/data
beaker.session.key = ark
beaker.session.secret = somesecret
sqlalchemy.default.url = sqlite:///%(here)s/data/project.db
*filter-with = slow

*[filter:slow]
*use=egg:waitforit
*time_limit=2
*poll_time=1

/snip

With the * lines being the new additions [minus the asterisk of course].
This does work, and I can use the wait for it message etc, however if the
pylons debugger needs to kick in it's now broken, with the following errors:

Traceback (most recent call last):
  File
c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\evalexception\mid
dleware.py, line 82, in simplecatcher_app
return application(environ, start_response)
  File
c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\httpexceptions.py
, line 636, in __call__
return self.application(environ, start_response)
  File
c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\evalexception\mid
dleware.py, line 117, in application
res = func(*args, **form.mixed())
  File
c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\evalexception\mid
dleware.py, line 140, in debug_info_replacement
debugcount = int(debugcount)
TypeError: int() argument must be a string or a number, not 'list'

Any help on how to stop this?

Jules


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---



Re: waitfor it and pylons debugger, WAS: Running a program without waiting for it to finish

2009-01-07 Thread Ian Bicking

Jules Stevenson wrote:
 Hi Ian,
 
 I didn't notice this thread first time around, but you might find
 WaitForIt (http://pythonpaste.org/waitforit/) helpful for cases like
 these; you could write the code as blocking and let WaitForIt deal with
 the long-running aspect.  (Assuming it runs for a long time, but
 eventually finishes -- if you need to interact with it over time you
 should stuff the process object in a module global)
 
 Thanks, this does indeed look like just the ticket. However I'm struggling
 to get this to work with Pylons correctly, specifically it seems to
 interfere with the debugger in the way that I have it set up [which is
 probably wrong].
 
 To set it up I came across a post
 (http://www.mail-archive.com/paste-us...@pythonpaste.org/msg00213.html) on
 the paste mailing list which contained the following info:
 
 ---
 so then I tried to
 use waitforit with pylons, so I made a new pylons app and added this to
 my test.ini file:
 
 [app:main]
 use = config:development.ini
 filter-with = slow
 
 [filter:slow]
 use=egg:waitforit
 time_limit=2
 poll_time=1
 ---
 
 I don't think I even use test.ini, so I modded my development.ini file to
 look like this:
 
 snip
 
 [app:main]
 use = egg:ark
 full_stack = true
 cache_dir = %(here)s/data
 beaker.session.key = ark
 beaker.session.secret = somesecret
 sqlalchemy.default.url = sqlite:///%(here)s/data/project.db
 *filter-with = slow
 
 *[filter:slow]
 *use=egg:waitforit
 *time_limit=2
 *poll_time=1
 
 /snip
 
 With the * lines being the new additions [minus the asterisk of course].
 This does work, and I can use the wait for it message etc, however if the
 pylons debugger needs to kick in it's now broken, with the following errors:
 
 Traceback (most recent call last):
   File
 c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\evalexception\mid
 dleware.py, line 82, in simplecatcher_app
 return application(environ, start_response)
   File
 c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\httpexceptions.py
 , line 636, in __call__
 return self.application(environ, start_response)
   File
 c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\evalexception\mid
 dleware.py, line 117, in application
 res = func(*args, **form.mixed())
   File
 c:\python26\lib\site-packages\paste-1.7.2-py2.6.egg\paste\evalexception\mid
 dleware.py, line 140, in debug_info_replacement
 debugcount = int(debugcount)
 TypeError: int() argument must be a string or a number, not 'list'
 
 Any help on how to stop this?

Hmm... I haven't seen this error, though generally it's better if
WaitForIt is wrapped only around those parts of your app that are slow.

I don't think Pylons controllers have a clear WSGI interface.  That's 
too bad, they should.  Here's a WSGI wrapper on a controller:

class MyController(BaseController):
 ...

def app(environ, start_response):
 return MyController()(environ, start_response)

MyController = WaitForIt(app)


I believe that will work, and then you can wrap just the controller that 
is likely to be slow.


-- 
Ian Bicking : i...@colorstudy.com : http://blog.ianbicking.org


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
pylons-discuss group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~--~~~~--~~--~--~---