当前位置: 首页>>代码示例>>Python>>正文


Python Event.created方法代码示例

本文整理汇总了Python中models.event.Event.created方法的典型用法代码示例。如果您正苦于以下问题:Python Event.created方法的具体用法?Python Event.created怎么用?Python Event.created使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.event.Event的用法示例。


在下文中一共展示了Event.created方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: push_event

# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import created [as 别名]
    def push_event(cls,
                   endpoint,
                   payload=None,
                   method='POST',
                   headers=None,
                   priority=0,
                   group_id=None):
        """
        Will push an event to the event queue.

        endpoint:   URL to call while executing the event
        payload:    Dictionary of GET params or body JSON
        method:     GET|POST
        headers:    Headers while executing the request
        priority:   Will be used to block events while lower priorities
                    events have failed. An event will only execute
                    if it' the next top priority on that group
        group_id:   Grouping of events, if None, an event will have it's
                    own unique group
        """
        if not payload:
            payload = {}

        if not group_id:
            group_id = guid()

        event = Event()
        event.created = datetime.datetime.now()
        event.headers = json.dumps(headers) or ''
        event.method = method
        event.payload = json.dumps(payload)
        event.endpoint = endpoint
        event.status = EventStatus.CREATED
        event.priority = priority
        event.group_id = group_id
        event.put()

        q = taskqueue.Queue(QUEUE_NAME)
        q.add([taskqueue.Task(
            name=cls._get_cutie_task_name(event.unique_id),
            payload=event.unique_id,
            method='PULL'
        )])
开发者ID:xplot,项目名称:imeet,代码行数:45,代码来源:event.py


注:本文中的models.event.Event.created方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。