Parse a PART and update channel states, then dispatch events.

    Note that two events are dispatched here:
        - PART, because a user parted the channel
        - MEMBERS, because the channel's members changed
185160
def _parse_part(client, command, actor, args):
    
    actor = User(actor)
    channel, _, message = args.partition(' :')
    channel = client.server.get_channel(channel)
    channel.remove_user(actor)
    if actor.nick == client.user.nick:
        client.server.remove_channel(channel)
    client.dispatch_event("PART", actor, channel, message)
    if actor.nick != client.user.nick:
        client.dispatch_event("MEMBERS", channel)
1008205
private void repartitionBroadcastState(
			Map<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>> broadcastState,
			List<Map<StreamStateHandle, OperatorStateHandle>> mergeMapList) {

		int newParallelism = mergeMapList.size();
		for (int i = 0; i < newParallelism; ++i) {

			final Map<StreamStateHandle, OperatorStateHandle> mergeMap = mergeMapList.get(i);

			// for each name, pick the i-th entry
			for (Map.Entry<String, List<Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo>>> e :
					broadcastState.entrySet()) {

				int previousParallelism = e.getValue().size();

				Tuple2<StreamStateHandle, OperatorStateHandle.StateMetaInfo> handleWithMetaInfo =
					e.getValue().get(i % previousParallelism);

				OperatorStateHandle operatorStateHandle = mergeMap.get(handleWithMetaInfo.f0);
				if (operatorStateHandle == null) {
					operatorStateHandle = new OperatorStreamStateHandle(
						new HashMap<>(broadcastState.size()),
						handleWithMetaInfo.f0);
					mergeMap.put(handleWithMetaInfo.f0, operatorStateHandle);
				}
				operatorStateHandle.getStateNameToPartitionOffsets().put(e.getKey(), handleWithMetaInfo.f1);
			}
		}
	}
539811
def handle_stage_changed(self, model):
        '''
        
        '''
        stages = model.get_stages()
        if self.dataman:
            self.dataman.set('stages', stages)
500211
def post_change_receiver(self, instance: Model, action: Action, **kwargs):
        
        try:
            old_group_names = instance.__instance_groups.observers[self]
        except (ValueError, KeyError):
            old_group_names = set()

        if action == Action.DELETE:
            new_group_names = set()
        else:
            new_group_names = set(self.group_names(instance))

        # if post delete, new_group_names should be []

        # Django DDP had used the ordering of DELETE, UPDATE then CREATE for good reasons.
        self.send_messages(
            instance,
            old_group_names - new_group_names,
            Action.DELETE,
            **kwargs
        )
        # the object has been updated so that its groups are not the same.
        self.send_messages(
            instance,
            old_group_names & new_group_names,
            Action.UPDATE,
            **kwargs
        )

        #
        self.send_messages(
            instance,
            new_group_names - old_group_names,
            Action.CREATE,
            **kwargs
        )
923080
function (next) {

    // If this is the first part, and we're just starting,
    // but we have a multipartUploadID, then we're beginning
    // a resume and can fire the 'ready' event externally.
    if (multipartUploadID && !started)
      ws.emit('ready', multipartUploadID);

    started = true;

    if (pendingParts < concurrentPartThreshold) {
      // Has the MPU been created yet?
      if (multipartUploadID)
        upload(); // Upload the part immediately.
      else {
        e.once('ready', upload); // Wait until multipart upload is initialized.
        createMultipartUpload();
      }
    }
    else {
      // Block uploading (and receiving of more data) until we upload
      // some of the pending parts
      e.once('part', upload);
    }

    function upload() {

      // Pause/resume check #2 out of 2:
      //   Block queued up parts until resumption.
      if (paused)
        e.once('resume', uploadNow);
      else
        uploadNow();

      function uploadNow() {
        pendingParts++;
        flushPart(function (partDetails) {
          --pendingParts;
          e.emit('part'); // Internal event
          ws.emit('part', partDetails); // External event

          // if we're paused and this was the last outstanding part,
          // we can notify the caller that we're really paused now.
          if (paused && pendingParts === 0)
            notifyPaused();
        });
        next();
      }
    }
  }
1110922
def merge(*other_incidents)
      merged_events = other_incidents.flatten.inject(events) do |events, incident|
        events += incident.events
      end
      Incident.new(merged_events.sort, triggering_event)
    end
283432
function() {
			var context = this.loopContext;
			var choiceContext = this.choiceContext;
			var forkContext = this.forkContext;

			// Update state.
			if (context.updateSegments) {
				context.endOfUpdateSegments = forkContext.head;

				// `update` -> `test`
				if (context.testSegments) {
					makeLooped(
						this,
						context.endOfUpdateSegments,
						context.testSegments);
				}
			} else if (context.testSegments) {
				finalizeTestSegmentsOfFor(
					context,
					choiceContext,
					forkContext.head);
			} else {
				context.endOfInitSegments = forkContext.head;
			}

			var bodySegments = context.endOfTestSegments;

			if (!bodySegments) {

				/*
				 * If there is not the `test` part, the `body` path comes from the
				 * `init` part and the `update` part.
				 */
				var prevForkContext = ForkContext.newEmpty(forkContext);

				prevForkContext.add(context.endOfInitSegments);
				if (context.endOfUpdateSegments) {
					prevForkContext.add(context.endOfUpdateSegments);
				}

				bodySegments = prevForkContext.makeNext(0, -1);
			}
			context.continueDestSegments = context.continueDestSegments || bodySegments;
			forkContext.replaceHead(bodySegments);
		}
889905
def _process_content_body(self, channel, payload):
        
        partial = self.partial_messages[channel]
        partial.add_payload(payload)
        if partial.complete:
            #
            # Stick the message in the queue and go back to
            # waiting for method frames
            #
            self.queue.put((channel, partial.method_sig, partial.args, partial.msg))
            del self.partial_messages[channel]
            self.expected_types[channel] = 1
773006
private void reSubscribeByName(EventChannelStruct eventChannelStruct, String name) {

        //  Get the map and the callback structure for channel
        Hashtable<String, EventCallBackStruct>
                callBackMap = EventConsumer.getEventCallbackMap();
        EventCallBackStruct callbackStruct = null;
        Enumeration channelNames = callBackMap.keys();
        while (channelNames.hasMoreElements()) {
            String  key = (String) channelNames.nextElement();
            EventCallBackStruct eventStruct = callBackMap.get(key);
            if (eventStruct.channel_name.equals(name)) {
                callbackStruct = eventStruct;
            }
        }

        //  Get the callback structure
        if (callbackStruct!=null) {
            callbackStruct.consumer.reSubscribeByName(eventChannelStruct, name);
        }
    }
453685
function handleAuthorizedState() {
        PermTransitionEvents.broadcastPermissionAcceptedEvent();

        // Overwrite notify option to broadcast it later
        var transitionOptions = angular.extend({}, PermTransitionProperties.options, {
          notify: false,
          location: true
        });

        $state
          .go(PermTransitionProperties.toState.name, PermTransitionProperties.toParams, transitionOptions)
          .then(function () {
            PermTransitionEvents.broadcastStateChangeSuccessEvent();
          });
      }
550513
private void resubscribe_if_needed() {
        Enumeration channel_names = EventConsumer.getChannelMap().keys();
        long now = System.currentTimeMillis();

        // check the list of not yet connected events and try to subscribe
        while (channel_names.hasMoreElements()) {
            String name = (String) channel_names.nextElement();
            EventChannelStruct eventChannelStruct = EventConsumer.getChannelMap().get(name);
            if ((now - eventChannelStruct.last_subscribed) > EVENT_RESUBSCRIBE_PERIOD / 3) {
                reSubscribeByName(eventChannelStruct, name);
            }
            eventChannelStruct.consumer.checkIfHeartbeatSkipped(name, eventChannelStruct);

        }// end while  channel_names.hasMoreElements()
    }
1208407
def dispatch(self, receiver):
        ''' 

        '''
        super(ColumnDataChangedEvent, self).dispatch(receiver)
        if hasattr(receiver, '_column_data_changed'):
            receiver._column_data_changed(self)
1072094
def part(self, *args, **kwargs):
        
        return self._client.part(*args, bucket=self.bucket.get('id'), **kwargs)
63744
def dispatch(self, receiver):
        ''' 

        '''
        super(ColumnsPatchedEvent, self).dispatch(receiver)
        if hasattr(receiver, '_columns_patched'):
            receiver._columns_patched(self)
275558
def part_channel(self, channel, reason=None, tags=None):
        """"""
        params = [channel]
        if reason:
            params.append(reason)
        self.send('PART', params=params, tags=tags)
289649
def join(self, event):
        

        try:
            channel_uuid = event.data
            user_uuid = event.user.uuid

            if channel_uuid in self.chat_channels:
                self.log('User joins a known channel', lvl=debug)
                if user_uuid in self.chat_channels[channel_uuid].users:
                    self.log('User already joined', lvl=warn)
                else:
                    self.chat_channels[channel_uuid].users.append(user_uuid)
                    self.chat_channels[channel_uuid].save()
                    packet = {
                        'component': 'hfos.chat.host',
                        'action': 'join',
                        'data': channel_uuid
                    }
                    self.fireEvent(send(event.client.uuid, packet))
            else:
                self.log('Request to join unavailable channel', lvl=warn)
        except Exception as e:
            self.log('Join error:', e, type(e), exc=True, lvl=error)
595461
private void dispatchServerChannelDeleteEvent(ServerChannel channel) {
        ServerChannelDeleteEvent event = new ServerChannelDeleteEventImpl(channel);

        api.getEventDispatcher().dispatchServerChannelDeleteEvent(
                (DispatchQueueSelector) channel.getServer(), channel.getServer(), channel, event);
    }