Thanks Max for your suggestion. I was skeptical not to do in the beginning, but my big Bro. wants me to learn both the safe server shutdown and client crash issues to be dealt cleanly. So only trying to learn.
But as you said, if I mess up anywhere anything, then the chances of pass are low

I can implement and learn these issues but not include in the project. Many thanks for the suggestion. Will stick to that.
Phil, as Max said, I will not include this in the project. But I am very much interested to know how we can deal this issue. The issue I was pointing toward unregistering is that becasue in the lock method, you are registering the object to the queue. But you are not clearing/removing the object from the queue. So what I am guessing is in the unlock method also once you remove the weakreference, though the key/value pair is removed from the lockedrecords, it will be still registered to the queue. And so as there is no reference to the weakreference now, whenever it gets garbage collected or about to, it will be added to the refqueue. So what I was thinking is we are supposed to remove/unregister the weakreference from the refqueue while removing the key/value pair in the unlock method. Maybe remove in RQ is not a good method as it will only remove the next available reference from the queue. I think clear from Reference should be exact to use in the unlock method to unregister it. What do you think, Phil? Am too crazy or reasonable thinking is going on?
Thanks for the comments.
Max, if you could also just clear things up, that would be really great. (Not in the exam point of view, but as a learning tool. Thanks)