[英]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. 如果我想一起分配5怎么办。
Is there any other function for my purpose? 我还有其他功能吗?
You can maybe use Environment.all_of()
您也许可以使用
Environment.all_of()
http://simpy.readthedocs.io/en/latest/topical_guides/events.html#waiting-for-multiple-events-at-once http://simpy.readthedocs.io/en/latest/topical_guides/events.html#waiting-for-multiple-events-at-once
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.