Wednesday, March 31, 2021

AWS - Retry messages from Dead Letter Queue

I have a SQS queue and a DLQ defined. 
Some messages were moved to DLQ because of some temoporary issue, so I wanted to move them back to the original queue for processing after the issue resolved.
The fastest way was:
1. Set the original queue as the DLQ on the DLQ queue with max receives 1
2. View the messages on DLQ, which moves the messages.
3. Remove the setting in 1.
 
I know there are some tools like this: https://github.com/garryyao/replay-aws-dlq , but in my case the above was the fastest solution.

Sunday, March 28, 2021

pip install issue - Retrying (Retry..

On my home Windows 10 I was getting an error when calling `pip install` command:

Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out.

I’ve seen posts where others had the same issue on Linux systems.

The solution for this issue was to disable IPv6.

On Windows, go to Properties of the network adapter, and find “Internet Protocol Version 6 (TCP/IPv6). Uncheck the checkbox and reboot (in my case reboot was not needed, but it is advised).

Saturday, March 27, 2021

Cunningham’s Law–Ask Dumb Things to Get Smart Answers

Cunningham's Law: "The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer."

Sherlock Holmes in The Great Game says, “people do not like telling you things; they love to contradict you”. Therefore if you want smart answers, do not ask a question. Instead, give a wrong answer or ask a question in such a way that it already contains the wrong information. It is highly likely that people will correct you.

Thursday, March 18, 2021

Terminal to Finder and back

On Mac it is usefull to switch between the Finder and a terminal window.
 
To open current Terminal path in Finder type:
 
open ./
 
To navigate in Terminal to some folder shown in the Finder, just drop it on the Terminal window.
 
 
 

Python profiling on Mac (Big Sur)

 I needed to profile a python app on my mac. Was it too much to ask? Apparently it was...

Anyhow for the most basic stuff the following articles helped a lot:

Python profiling

Handy Python profiling analysis with pstats interactive browser

I prefer not to change my code so call cProfile from the terminal like this:

python -m cProfile -o prof_results my_code.py

which would generate the prof_results file with the results.

Then call:

python -m pstats prof_results

to view the results.

`pstats` can filter and sort the output, but I couldn't find a way to show a nested view.


It seems that there are a few packages out there that are supposed to help better visualize the profiling results, but all/most of them are outdated or couldn't deal with the complexity of my output.

The only/best result I finally settled on was to use Spyder. 

Installation on Big Sur was not pleasant.  dmg installation is not working for me, and other options were problematic.

pip install spyder worked!

In order to profile in spyder follow this: Spyder Profiler