I liked this solutions, is pretty simple and functional, but i think it's better to declare this function inside the function which use this, in this case mini_receive, to avoid namespace conflicts and for a more readable code.

just put this def just after the def mini_receive statement.