简体   繁体   中英

How to request more than one resource in SimPy

I would like to have processes requesting more than one resource from the shared resources pool.

For instance, with this code I can only request one resource:

def job(pool, total_requested):
    with pool.request() as request:
        yield request

if __name__ == "__main__":
    env = simpy.Environment()
    pool = simpy.Resource(env, RESOURCES)
    env.process(job(pool, 5))
    env.run()

What if I would like to allocate 5 together.

Is there any other function for my purpose?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM