srlindsay / gevent-profiler

a greenlet aware profiling module
gevent-profiler
90 stars 19 forks source link

Allow setting the attach timeout #5

Closed daf closed 12 years ago

daf commented 12 years ago

I ran into some problems while trying to profile long-running operations - whenever my code eventually got to the detach method, it would just throw a python error. Tracing the steps, I figured it out there is a timeout involved, by default set to 60 seconds.

This patch does a few things:

srlindsay commented 12 years ago

Seems fine to me. I don't use attach directly in applications that I profile, instead using attach_on_signal which takes the profile duration as an argument. I suppose the signal-based trigger only makes sense if you're profiling a large amount of short tasks, rather than one long-running task.

srlindsay commented 12 years ago

So, the _attach_duration global was there only to allow attach_on_signal to work. Setting the duration makes way more sense as an argument to attach.

Take a look at the no_global_duration branch -- if that will work for you use case, I think I'd prefer to go that route, getting rid of _attach_duration and set_attach_duration.

daf commented 12 years ago

Yes, that looks great to me. Seems to be working fine here.