def send_notify(self, model, obj, msg, using):
        if model_name(model).split('.', 1)[0] in ('migrations', 'dddp'):
            return  # never send migration or DDP internal models

        new_col_connection_ids = self.valid_subscribers(model, obj, using)
        old_col_connection_ids = self._ddp_subscribers.get(
            using, {},
        ).get(
            model, {},
        ).pop(
            obj.pk, collections.defaultdict(set),
        )
        try:
            my_connection_id = this.ws.connection.pk
        except AttributeError:
            my_connection_id = None
        meteor_ids = {}
        for col in set(old_col_connection_ids).union(new_col_connection_ids):
            old_connection_ids = old_col_connection_ids[col]
            new_connection_ids = new_col_connection_ids[col]
            for (msg, connection_ids) in (
                    (REMOVED, old_connection_ids - new_connection_ids),
                    (CHANGED, old_connection_ids & new_connection_ids),
                    (ADDED, new_connection_ids - old_connection_ids),
            ):
                if not connection_ids:
                    continue  # nobody subscribed
                payload = col.obj_change_as_msg(obj, msg, meteor_ids)
                payload['_connection_ids'] = sorted(connection_ids)
                if my_connection_id is not None:
                    payload['_sender'] = my_connection_id
                    if my_connection_id in connection_ids:
                        # msg must go to connection that initiated the change
                        payload['_tx_id'] = this.ws.get_tx_id()
                # header is sent in every payload
                header = {
                    'uuid': uuid.uuid1().int,  # UUID1 should be unique
                    'seq': 1,  # increments for each 8KB chunk
                    'fin': 0,  # zero if more chunks expected, 1 if last chunk.
                }
                data = ejson.dumps(payload)
                cursor = connections[using].cursor()
                while data:
                    hdr = ejson.dumps(header)
                    # use all available payload space for chunk
                    max_len = 8000 - len(hdr) - 100
                    # take a chunk from data
                    chunk, data = data[:max_len], data[max_len:]
                    if not data:
                        # last chunk, set fin=1.
                        header['fin'] = 1
                        hdr = ejson.dumps(header)
                    # print('NOTIFY: %s' % hdr)
                    cursor.execute(
                        'NOTIFY "ddp", %s',
                        [
                            '%s|%s' % (hdr, chunk),  # pipe separates hdr|chunk.
                        ],
                    )
                    header['seq'] += 1  # increment sequence.
Merge gene lists into single table and load into SQLite.
dataset/ETHPy150Open django-ddp/django-ddp/dddp/api.py/DDP.send_notify--crossover with--dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_species_conservation.py/mergeGeneLists