Exemplo n.º 1
0
def test_large_stdout_blob():
    def _callback(*args, **kw):
        pass

    f = OutputEventFilter(_callback)
    for x in range(1024 * 10):
        f.write('x' * 1024)
Exemplo n.º 2
0
    def wrap_stdout_handle(instance,
                           private_data_dir,
                           stdout_handle,
                           event_data_key='job_id'):
        dispatcher = CallbackQueueDispatcher()

        def job_event_callback(event_data):
            event_data.setdefault(event_data_key, instance.id)
            if 'uuid' in event_data:
                filename = '{}-partial.json'.format(event_data['uuid'])
                partial_filename = os.path.join(private_data_dir, 'artifacts',
                                                'job_events', filename)
                try:
                    with codecs.open(partial_filename, 'r',
                                     encoding='utf-8') as f:
                        partial_event_data = json.load(f)
                    event_data.update(partial_event_data)
                except IOError:
                    if event_data.get('event', '') != 'verbose':
                        logger.error(
                            'Missing callback data for event type `{}`, uuid {}, job {}.\nevent_data: {}'
                            .format(event_data.get('event',
                                                   ''), event_data['uuid'],
                                    instance.id, event_data))
            dispatcher.dispatch(event_data)

        return OutputEventFilter(stdout_handle, job_event_callback)
Exemplo n.º 3
0
def wrapped_handle(job_event_callback):
    # Preliminary creation of resources usually done in tasks.py
    return OutputEventFilter(job_event_callback)