dr. Igor K
dr. Igor K

Reputation: 1

TypeError: '>' not supported between instances of 'float' and 'Synchronized'

if math.fabs(time.time()-start_time) > time_interval :

TypeError: '>' not supported between instances of 'float' and 'Synchronized'

Code:

if __name__ == "__main__":
    start_time =  multiprocessing.Value( 'd', 0.0)
    time_t = multiprocessing.Value('d', 0.005)
    producer(all_client, q[0], time_t, start_time, t)

...

def producer(sequence, output_q, time_interval, start_time, t):
    start_time = t = time.time()
    for item in sequence:
        time.sleep(random.expovariate(glamda[0]))
        item.time_arrived = item.V_entered[0]= time.time()
        output_q.put(item)
        
        if math.fabs(time.time()-start_time) > time_interval :
            print("producer time out ", time_t)
            break 

Upvotes: -1

Views: 608

Answers (1)

Aleksandr Fuze
Aleksandr Fuze

Reputation: 336

I'm not sure what you want to get. But you can resolve this error by just get the value from Synchronized object (this is not float, you may extract value from this object).
replace:
if math.fabs(time.time()-start_time) > time_interval
to:
if math.fabs(time.time()-start_time) > time_interval.value

Upvotes: 0

Related Questions