Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

HTTPClient not thread safe #144

@jkhelil

Description

@jkhelil

I want to use consul python module in a multiprocessing context : I need to execute x process and each of them is fetching node from consul with are advertising a special service, with special tag
To give you an idea, the code is almost this

def run:
    job = []
    for item in list_a:
        job = multiprocessing.Process(name='Process' + item, target=process,
                                      args=(item))
        job.daemon = False
        jobs.append(job)
        job.start()
    for job in jobs:
        job.join()


def process(item):
    consul_api.health.service(MY_SERVICE, tag=item, dc=datacenter)

I was printing in base.py the result of the request and there was wrong results, I add this to service method of class Health

print "------------------%s %s %s" % (service,tag,self.agent.http.get(
                CB.json(index=True),
                '/v1/health/service/%s' % service,
                params=params))

the was mixed results
let say for tag1, it returns result for tag2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions