def process_group(hg, crawl_id, requesters, processed_groups, dbpool):
    """Gevent worker that should process single hitgroup.

    This should write some data into database and do not return any important
    data.
    """
    hg['keywords'] = ', '.join(hg['keywords'])
    # for those hit goups that does not contain hash group, create one and
    # setup apropiate flag

    hg['qualifications'] = ', '.join(hg['qualifications'])

    conn = dbpool.getconn(thread.get_ident())
    db = DB(conn)
    try:
        hit_group_content_id = db.hit_group_content_id(hg['group_id'])
        if hit_group_content_id is None:
            # check if there's profile for current requester and if does
            # exists with non-public status, then setup non public status for
            # current hitsgroup content
            profile = requesters.get(hg['requester_id'], None)
            if profile and profile.is_public is False:
                hg['is_public'] = False
            else:
                hg['is_public'] = True
            # fresh hitgroup - create group content entry, but first add some data
            # required by hitgroup content table
            hg['occurrence_date'] = datetime.datetime.now()
            hg['first_crawl_id'] = crawl_id
            if not hg['group_id_hashed']:
                # if group_id is hashed, we cannot fetch details because we
                # don't know what the real hash is
                hg.update(hits_group_info(hg['group_id']))
            else:
                hg['html'] = ''
            hit_group_content_id = db.insert_hit_group_content(hg)
            log.debug('new hit group content: %s;;%s',
                    hit_group_content_id, hg['group_id'])

        hg['hit_group_content_id'] = hit_group_content_id
        hg['crawl_id'] = crawl_id
        hg['now'] = datetime.datetime.now()
        db.insert_hit_group_status(hg)
        conn.commit()
    except Exception:
        processed_groups.remove(hg['group_id'])
        log.exception('process_group fail - rollback')
        conn.rollback()
    finally:
        db.curr.close()
        dbpool.putconn(conn, thread.get_ident())
        msg = ('This really should not happen, Hitgroupstatus was processed but'
            ' is not on the list, race condition?')
        assert processed_groups in hg['group_id'], msg

    return True
dataset/ETHPy150Open ipeirotis/Mturk-Tracker/app/mturk/main/management/commands/crawler/tasks.py/process_group/swapped operands of `in`