Detect worker node vs http request

54 views
Skip to first unread message

Benson Myrtil

unread,
Nov 6, 2015, 2:15:33 PM11/6/15
to web2py-users
Is there an easy way to detect if it is a worker making a request vs an http request?

Anthony

unread,
Nov 6, 2015, 2:34:20 PM11/6/15
to web2py-users
On Friday, November 6, 2015 at 2:15:33 PM UTC-5, Benson Myrtil wrote:
Is there an easy way to detect if it is a worker making a request vs an http request?

For now:

cmd_options = request.global_settings.cmd_options
if cmd_options and cmd_options.scheduler:
   
[this is a worker running a scheduled task]

In trunk (but not yet in the current stable release):

if request.is_scheduler:

request.is_scheduler has been available for some time, but there was a bug that was only recently fixed, so it won't work until the next stable release.

Anthony

Benson Myrtil

unread,
Nov 14, 2015, 11:28:10 AM11/14/15
to web2py-users
Just noticed I don't believe this code works on PC using nssm. the cmd_options.scheduler is still None
Reply all
Reply to author
Forward
0 new messages