mandrewcito / signalrcore

SignalR Core python client
https://mandrewcito.github.io/signalrcore/
MIT License
115 stars 53 forks source link

The headers variable initialization method is not correct. In the case of multiple threads, headersr of multiple instances points to the same memory address, causing tokens to overwrite each other #72

Closed Deng2016 closed 2 years ago

Deng2016 commented 2 years ago

Describe the bug In the HubConnectionBuilder, AuthHubConnection, BaseHubConnection and other three classes, the way to initialize the headers variable is: headers={}

It is normal to use in a single thread, but when used in multiple threads, all headers point to the same memory address, which will cause the token to be overwritten by the last object.

// Comparison of the two initialization methods of the dictionary 
// {}
print(id({}))
print(id({}))
print(id({}))

// dict()
print(id(dict()))
print(id(dict()))
print(id(dict()))

/* Post run output
1984312275072
1984312275072
1984312275072
1984315991552
1984315990848
1984316002560
*/