Hello! I have about a code that needs blocking:
self.search_params['my_sex'] = '' self.search_params['wish_sex'] = 'F' with (yield self.application.search_lock.acquire()): for uid in self.application.inSearch: if isComplyUsers(self.search_params, self.application.pool[uid]): self.connected(self.uid, uid) self.application.inSearch.pop(uid) return True self.application.inSearch.append(self.uid) The function itself isComplyUsers:
def isComplyUsers(user, user1): if(user['my_sex']!='' and user['wish_sex']!='' and user['wish_sex']!=user1['my_sex']): return False return True self.application.search_lock - tornado.locks.Lock ()
Of course, I reduced the code, separating only the main points because of what the error occurs.
Sometimes an error pops up in the log:
__del__ future <tornado.object.concurrent.Future object exception And he complains about KeyError, and says that 'my_sex' does not exist in the user object. So one wonders why he calls this function at all in his destructor "__del__". And if I just check for the emptiness of the object - will this be a solution? Also, I noticed that the error appears only if search_params ['my_sex'] = '' is exactly equal to emptiness, if it is not equal to something empty, then an error does not occur.