The importance of getting enough sleep as a developer

The importance of getting enough sleep as a developer

/ #Misc


Going to bed to solve a problem instead of almost throwing your computer in the wall.

A few nights ago I was struggling with a bug in my code, if I can call it that. I created a script using Python for checking if a image uploaded from web had the wrong orientation and I could not figure out why I couldn't pull the exif tags using PIL. I just got this stupid error saying the NoneType had noe items or something similar.

Different versions of PIL

I was sure the code locally was working, but there was an error on the live server. So I had this eureka moment when I run "pip freeze" local and live, there was a difference between my versions of PIL. I got excited and changed it live, but the error was still there. I started to think that my code might still be using the old version of PIL or something like that, so I kept digging. I ended up uploading a image I knew had exif tags (they can be removed) and tried a part of the script direcly in the python interpreter and it worked. So why did it not work in my Django project?

I Googled for a while and tested a lot. The clock kept ticking, I got more and more tired and more and more frustrated with this silly little thing. So after x number of hours I went to sleep, pissed off at my self for wasting so much time.

Permission denied

I woke up the morning after and then I manually run the project at the live server and I see that I get a permission denied error. The folder where the images was saved was owned by root. Were this the problem all along? Turned out it was not. I changed it back to django-user and the same old error was popping up. It was just changed to root because I testet the script as root user last night.

But my mind had rested well and just looking at the code made me realize almost right away what the problem was. I resized the uploaded image using PIL and after this I checked if the image had the correct orientation. If you know how PIL works you know that when you create a thumbnail all of the exif tags are removed and that contains information about the orientation.

Rested and small breaks

So just sleeping that night and making sure my mind was rested was enough to make me understand that little mistake in my code. Of course you can't just go to sleep everytime you run into a problem, that would not be very productive. But instead of getting stuck for hours on a bug and get frustrated, take 5-10 minutes of fresh air. Those few minutes can do wonder to your thinking.

Want to read about how to be productive in the morning? The best morning routine for a productive day.

Comments

No comments yet...

Add comment

Newsletter

Subscribe to my weekly newsletter. One time per week I will send you a short summary of the tutorials I have posted in the past week.