想知道是否有人可以在这里帮助我
RANDOM_SEED = 181106
NbrMtgs = 5 # Total number of meetings in a period
INTERVAL = 1.0 # Generate new meetings every x hours
def Schedule(env, NbrMtgs, interval, ResRooms):
#Source generates meetings
while True:
for i in range(NbrMtgs):
h=env.now
m = Meet(env, 'Meeting%02d_%02d' % (h,i), ResRooms, TimeInMtg=MtgLen)
env.process(m)
t = 1
yield env.timeout(t)
def Meet(env, name, ResRooms, TimeInMtg):
#Customer arrives, is served and leaves.
arrive = env.now
print('%7.4f %s: Here I am' % (arrive, name))
with ResRooms.request() as req:
results = yield req | env.timeout(MtgLen)
wait = env.now - arrive
if req in results:
# We got to the ResRooms
print('%7.4f %s: Waited %6.3f' % (env.now, name, wait))
#tib = random.expovariate(1.0 / TimeInMtg)
yield env.timeout(TimeInMtg)
print('%7.4f %s: Finished' % (env.now, name))
else:
# We reneged
#req.cancel() this doesnt clear queue and does give an error at last step
# no notable effect ResRooms.release(req)
#simpy.Interrupt('No rooms') still piling up. no effect
#yield env.timeout(TimeInMtg)
print('%7.4f %s: RENEGED after %6.3f' % (env.now, name, wait))
print("this req=",req) # is something like <Request() object at 0x2449892f908>
print("users",ResRooms.users)
print("queue",ResRooms.queue)
env = simpy.Environment()
# Start processes and run
ResRooms = simpy.Resource(env, capacity=3)
MtgLen = 1
Hours = 8
env.process(Schedule(env, NbrMtgs, INTERVAL, ResRooms))
env.run(until=5)
如您所见,我使用API密钥正确设置了标头,但由于某种原因,我得到了409返回值,这是缺少的“用户密钥”。
任何人都经历过这样的事情。对于它的价值,完全相同的请求正在Paw中工作
答案 0 :(得分:1)
您必须根据文档link documentation here
提供信息示例:
var publickey = 'you-public-key';
var privatekey = 'you-private-key';
var ts = new Date().getTime();
var stringToHash = ts + privatekey + publickey;
var hash = md5(stringToHash);
var baseUrl = 'https://gateway.marvel.com:443/v1/public/characters';
var limit = 20;
var url = baseUrl + '?limit=' + limit + '&ts=' + ts + '&apikey=' + publickey + '&hash=' + hash;