thank for you answer i use python G:\\web2py\\web2py.py -K yj:sss -X -a '1' -i 0.0.0.0 -p 8000 & to run my app,can you give me a example ? i understand the script,but i don't know how to use it in my app and when i use scheduler it auto use threading create so many task, i want to control it's quantity,how to do?
在 2017年11月15日星期三 UTC+8下午11:29:38,Anthony写道: > > How are you starting the scheduler workers? Typically the scheduler is run > in the context of a web2py app environment, so the database and tasks are > defined in a web2py app. > > To run the scheduler outside of the web2py context, see > https://github.com/web2py/web2py/blob/c9fd0fd71e770c1a367b45ad5def5bd2c6fd7115/gluon/scheduler.py#L1637. > > You'll need to specify the DB URI, a folder where the DAL model definition > metadata files will be stored, and a file where the tasks are defined. > > Anthony > > On Wednesday, November 15, 2017 at 4:04:15 AM UTC-5, yytr...@gmail.com > <javascript:> wrote: >> >> i write a scripy to get some information and use scheduler to auto ,but >> scheduler is display FAILED,this is my script >> >> def redhat(): >> bug_num ='' >> try: >> try: >> url = 'https://access.redhat.com/security/vulnerabilities' >> rea = requests.get(url) >> rea.encoding = 'utf-8' >> html = BeautifulSoup(rea.text,"html.parser") >> a= html.find("tbody").find_all("tr") >> try: >> indatabase = db(db.get_data.get_from == "redhat").select >> () >> if indatabase: >> indatabase=db(db.get_data.get_from == "redhat"). >> select( >> db.get_data.title,orderby=~db.get_data.get_time, >> limitby=(0,5)) >> else: >> indatabase=['1'] >> except BaseException as e: >> print e >> for i in range(len(a)): >> for j in indatabase: >> break_flag ='no' >> if a[i].find("a").get_text() != j.title: >> geturl = 'https://access.redhat.com'+ str(a[i]. >> find("a")).split('"')[1] >> bug_level = a[i].find("div", >> "field-type-list-text").get_text().strip() >> if re.findall(u'CVE\-[0-9]{4,}\-[0-9]{4,}',str(a[ >> i].find("a").get_text())): >> bug_num = re.findall(u >> 'CVE\-[0-9]{4,}\-[0-9]{4,}',str(a[i].find("a").get_text()))[0] >> if bug_level=="Critical": >> bug_level="High" >> elif bug_level=="Important": >> bug_level=" Medium" >> elif bug_level=="Moderate": >> bug_level="Low" >> db.get_data.insert(title=a[i].find("a").get_text >> (),get_from='redhat',get_url=geturl,get_time=now, >> body='',data_condition=condition[0],bug_num= >> bug_num,bug_level=bug_level) >> print a[i].find("a").get_text() >> break >> else: >> break_flag = "yes" >> print "redhat no new isuse" >> break >> if break_flag == "yes": >> break >> >> >> except Exception as e: >> print e >> >> except Exception as e: >> pass >> print "redhat finish in " +str(datetime.datetime.now()) +"\n" >> >> >> from datetime import timedelta as timed >> from gluon.scheduler import Scheduler >> scheduler = Scheduler(db, dict( >> mission5=redhat >> ) >> ) >> scheduler.queue_task('mission5', >> start_time=request.now, # datetime >> stop_time=None,#request.now+timed(seconds=30), # datetime >> timeout = 90, # seconds >> period=60, # seconds >> immediate=True, >> repeats=1 >> ) >> my script can normal run in controllers,but in scheduler can't >> and i want to control the quantity of scheduler_task,but it without stop >> create new task ,please help me >> > -- 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.