标签: scheduler

Spring的@Scheduled错误:上下文中只能存在一个AsyncAnnotationBeanPostProcessor

我正在尝试Spring 3的@Scheduled注释.这是我的配置(app.xml):

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xmlns:task="http://www.springframework.org/schema/task"
  xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
      http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
      http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
      http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
      http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.0.xsd
      "
>

  <context:component-scan base-package="destiny.web"/>  
  <context:annotation-config/>
  // other beans

  <task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>
  <task:executor  id="myExecutor"  pool-size="5"/>
  <task:scheduler id="myScheduler" pool-size="10"/>
</beans>
Run Code Online (Sandbox Code Playgroud)

这是我的服务类:

@Service
public class ServiceImpl implements Service , Serializable
{
  //other injections

  @Override
  @Transactional
  public void timeConsumingJob()
  {
    try
    {
      Thread.sleep(10*1000);
    }
    catch (InterruptedException e)
    {
      e.printStackTrace();
    }
  }

  @Override
  @Scheduled(cron="* * * * * ?") 
  public void secondly() …
Run Code Online (Sandbox Code Playgroud)

spring scheduler crontrigger spring-3

25
推荐指数
4
解决办法
3万
查看次数

*和?之间的区别 在Spring @Scheduled(cron =".....")

我一直在寻找春天引导例如调度任务(https://spring.io/guides/gs/scheduling-tasks/),并通过一些文档阅读(https://javahunter.wordpress.com/2011/05/05/cronscheduler-in-spring /)我看到*和?几乎可互换使用.

例如,该行

@Scheduled(cron = "0 15 10 ? * *")
Run Code Online (Sandbox Code Playgroud)

@Scheduled(cron = "0 15 10 * * ?")
Run Code Online (Sandbox Code Playgroud)

做同样的事情.那么*和?之间的区别是什么?

java cron spring scheduler scheduled-tasks

25
推荐指数
2
解决办法
9737
查看次数

Python - 在给定时间启动函数

如何在给定时间在Python中运行函数?

例如:

run_it_at(func, '2012-07-17 15:50:00')
Run Code Online (Sandbox Code Playgroud)

它将func在2012-07-17 15:50:00 运行该功能.

我尝试了sched.scheduler,但它没有启动我的功能.

import time as time_module
scheduler = sched.scheduler(time_module.time, time_module.sleep)
t = time_module.strptime('2012-07-17 15:50:00', '%Y-%m-%d %H:%M:%S')
t = time_module.mktime(t)
scheduler_e = scheduler.enterabs(t, 1, self.update, ())
Run Code Online (Sandbox Code Playgroud)

我能做什么?

python time scheduler

24
推荐指数
5
解决办法
6万
查看次数

是否可以在Web应用程序中运行cron作业?

在java web应用程序(servlets/spring mvc)中,使用tomcat,是否可以运行cron作业类型服务?

例如,每隔15分钟,清除日志数据库.

你能以独立于容器的方式执行此操作,还是必须使用tomcat或其他容器运行?

请指定方法是保证在特定时间运行还是每15分钟运行一次,但如果应用程序循环使用,则可以重置等(如果使用计时器,则为.net中的方式)

java cron tomcat scheduler scheduled-tasks

23
推荐指数
1
解决办法
2万
查看次数

一旦我认为它已经完成,如何在ScheduledThreadPoolExecutor中停止任务

我有一个ScheduledThreadPoolExecutor,我用它来安排一个以固定速率运行的任务.我希望任务以指定的延迟运行最多10次,直到它"成功".在那之后,我不希望重试任务.所以基本上我需要停止运行计划任务,当我希望它被停止时,但不关闭ScheduledThreadPoolExecutor.知道我怎么做吗?

这是一些伪代码 -

public class ScheduledThreadPoolExecutorTest
{
  public static ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(15);  // no multiple instances, just one to serve all requests

  class MyTask implements Runnable
  {
    private int MAX_ATTEMPTS = 10;
    public void run()
    {
      if(++attempt <= MAX_ATTEMPTS)
      {
        doX();
        if(doXSucceeded)
        {
          //stop retrying the task anymore
        }
      }
      else
      { 
        //couldn't succeed in MAX attempts, don't bother retrying anymore!
      }
    }
  }

  public void main(String[] args)
  {
    executor.scheduleAtFixedRate(new ScheduledThreadPoolExecutorTest().new MyTask(), 0, 5, TimeUnit.SECONDS);
  }
}
Run Code Online (Sandbox Code Playgroud)

java scheduling scheduler scheduled-tasks

21
推荐指数
3
解决办法
3万
查看次数

GWT:计时器和调度程序类

我已多次阅读此页面,我只是没有看到GWT TimerScheduler类之间的一些固有差异.我正在寻找以下各项的用例和适用性:

  • Timer,Timer::scheduleTimer::scheduleRepeating
  • Scheduler::scheduleDeferred
  • Scheduler::scheduleIncremental
  • IncrementalCommand
  • DeferredCommand

这些似乎都在做同样的事情,或多或少,感觉你可以完成所有这些目标.这只是GWT的方式,提供多种方式做同样的事情?如果没有,请帮助我了解每个适当使用的时间和地点.

java gwt scheduler

20
推荐指数
2
解决办法
2万
查看次数

18
推荐指数
2
解决办法
2万
查看次数

无法找到记录器"apscheduler.scheduler"的处理程序

from apscheduler.scheduler import Scheduler
import os
class ListHref():
    def __init__(self):
       print 'In ListHref Class!'
       self.name_hrefs = {}
       self.name_img = {}
       self.path = os.path.dirname(__file__)
       print 'Out ListHref Class'
    def other_function():...

def job(): #function named job
    print 'In job!'
    book_href = ListHref()
    print 'book_href created!'

if __name__ == "__main__":
    sched = Scheduler()
    #job() #it's ok if job() called only
    sched.daemonic = False #non daemon thread 
    sched.add_interval_job(job,minutes=0.1)
    sched.start()
Run Code Online (Sandbox Code Playgroud)

问题: 如果只调用job()而不是sched,那就没关系所以我很困惑为什么init(self)不能完全调用?什么错了'没有handerls可以找到记录器"apscheduler.scheduler"'? 以上python代码结果:

在工作()

在ListHref类中!

没有找到记录器"apscheduler.scheduler"的handerls

在工作()

在ListHref类中!

在工作()

在ListHref类中!

...(等等)

python scheduler

18
推荐指数
1
解决办法
3万
查看次数

为什么Linux的调度程序将两个线程放在具有超线程的处理器上的同一物理内核上?

我已经在多个地方读过Linux的默认调度程序在多核机器上的超线程感知,这意味着如果你有一台具有2个真实内核(4 HT)的机器,它将不会以某种方式将两个忙线程安排到逻辑内核上它们都运行在相同的物理内核上(在许多情况下会导致2倍的性能成本).

但是当我stress -c 2在我的Intel i5-2520M上运行(产生两个线程以在100%CPU上运行)时,它经常将两个线程调度(并保持)到HT核心1和2上,这些核心映射到相同的物理核心.即使系统处于空闲状态.

这也适用于真正的程序(我在stress这里使用它因为它很容易重现),当发生这种情况时,我的程序可以理解地需要两倍的时间来运行.手动设置亲和力与taskset我的程序的修复程序,但我希望HT感知调度程序自己正确地执行此操作.

您可以找到HT->物理核心配置egrep "processor|physical id|core id" /proc/cpuinfo | sed 's/^processor/\nprocessor/g'.

所以我的问题是:为什么调度程序将我的线程放在同一个物理内核上?


笔记:

  • 这个问题与其他问题非常相似,答案就是说Linux有一个非常复杂的线程调度程序,它具有HT意识.如上所述,我无法观察到这一事实(请自行检查stress -c),并想知道原因.
  • 我知道我可以手动为我的程序设置处理器亲和性,例如使用taskset工具或sched_setaffinity函数.这不是我正在寻找的,我希望调度程序能够自己知道将两个忙线程映射到物理核心并将一个物理核心完全留空并不是一个好主意.
  • 我知道在某些情况下你更喜欢将线程安排到同一个物理内核上并让其他内核保持空闲,但调度程序大约1/4的情况下,这似乎是荒谬的.在我看来,它所选择的HT核心是完全随机的,或者可能是那些在调度时活动最少的HT核心,但这并不是非常超线程的意识,考虑到具有stress受益于在不同的物理核心上运行.

linux performance multithreading scheduler

18
推荐指数
2
解决办法
5071
查看次数

调度程序,如MVC中的谷歌日历

我正在尝试将Google日历中的日历插件与自定义数据库和代码与C#中的asp.net MVC集成.

它需要像谷歌日历一样处理日历中的日/周/月事件.

我在jquery http://www.webappers.com/2009/08/04/jquery-weekly-calendar-plugin-inspired-by-google-calendar/中找到了类似的插件.但它只显示了周

有人提到这个吗?请建议

c# asp.net-mvc jquery scheduler fullcalendar

17
推荐指数
2
解决办法
3万
查看次数