# Buggy code
def sendChatAction(self, chat_id, action):
    """Use this method when you need to tell the user that something is
    happening on the bot's side. The status is set for 5 seconds or less
    (when a message arrives from your bot, Telegram clients clear its
    typing status).

    Args:
      chat_id:
        Unique identifier for the message recipient - User or GroupChat id.
      action:
        Type of action to broadcast. Choose one, depending on what the user
        is about to receive:
        - ChatAction.TYPING for text messages,
        - ChatAction.UPLOAD_PHOTO for photos,
        - ChatAction.UPLOAD_VIDEO or upload_video for videos,
        - ChatAction.UPLOAD_AUDIO or upload_audio for audio files,
        - ChatAction.UPLOAD_DOCUMENT for Lesser files,
        - ChatAction.FIND_LOCATION for location data.
    """

    url = "%s/sendChatAction" % self.base_url

    data = {"chat_id": chat_id, "action": action}

    return url, data


# Traceback (TypeError)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/pickle.py", line 1370, in dump
Pickler(file, protocol).dump(obj)
File "/usr/lib/python2.7/pickle.py", line 224, in dump
self.save(obj)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 600, in save_list
self._batch_appends(iter(obj))
File "/usr/lib/python2.7/pickle.py", line 615, in _batch_appends
save(x)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 331, in save
self.save_reduce(obj=obj, *rv)
File "/usr/lib/python2.7/pickle.py", line 419, in save_reduce
save(state)
File "/usr/lib/python2.7/pickle.py", line 286, in save
f(self, obj) # Call unbound method with explicit self
File "/usr/lib/python2.7/pickle.py", line 649, in save_dict
self._batch_setitems(obj.iteritems())
File "/usr/lib/python2.7/pickle.py", line 663, in _batch_setitems
save(v)
File "/usr/lib/python2.7/pickle.py", line 306, in save
rv = reduce(self.proto)
File "/home/leandrotoledo/workspace/python-telegram-bot/env/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: can't pickle lock objects

# Fixed code
def sendChatAction(self, chat_id, action):
    """Use this method when you need to tell the user that something is
    happening on the bot's side. The status is set for 5 seconds or less
    (when a message arrives from your bot, Telegram clients clear its
    typing status).

    Args:
      chat_id:
        Unique identifier for the message recipient - User or GroupChat id.
      action:
        Type of action to broadcast. Choose one, depending on what the user
        is about to receive:
        - ChatAction.TYPING for text messages,
        - ChatAction.UPLOAD_PHOTO for photos,
        - ChatAction.UPLOAD_VIDEO or upload_video for videos,
        - ChatAction.UPLOAD_AUDIO or upload_audio for audio files,
        - ChatAction.UPLOAD_DOCUMENT for general files,
        - ChatAction.FIND_LOCATION for location data.
    """

    url = "%s/sendChatAction" % self.base_url

    data = {"chat_id": chat_id, "action": action}

    return url, data