SoundCloud python api and GAE upload larger sounds
Question: I've been testing the SoundCloud Python API and it was working great with
smaller files (< 1MB). Now, I'm trying to upload larger files (5MB+) and I'm
getting errors.

Here's the code:

    
    
    import soundcloud
    client = soundcloud.Client(
            client_id = app.config['SOUNCLOUD_CLIENT_ID'] ,
            client_secret= app.config['SOUNCLOUD_CLIENT_SECRET'],
            username= app.config['SOUNCLOUD_CLIENT_USERNAME'],
            password= app.config['SOUNCLOUD_CLIENT_PASSWORD'])
    try:
        track = client.post('/tracks', track={
                  'title':  request.form['song_title'],
                  'sharing': 'public',
                  'asset_data': blob_reader})
    except Exception, e:
                   logging.info(xstr(e))
    

Here's the error logs:

    
    
    INFO     2014-09-05 18:29:27,199 connectionpool.py:657] Starting new HTTPS connection (1): api.soundcloud.com
    
    INFO     2014-09-05 18:29:39,863 views.py:2308] HTTPSConnectionPool(host='api.soundcloud.com', port=443): Max retries exceeded with url: /tracks.json (Caused by <class 'google.appengine.dist27.gae_override.httplib.HTTPException'>: Deadline exceeded while waiting for HTTP response from URL: https://api.soundcloud.com/tracks.json)
    
    INFO     2014-09-05 18:29:39,914 recording.py:665] Saved; key: __appstats__:064700, part: 157 bytes, full: 222910 bytes, overhead: 0.004 + 0.050; link: http://localhost:8080/_ah/stats/details?time=1409941764737
    
    INFO     2014-09-05 18:29:39,926 module.py:640] default: "POST /scimageupload HTTP/1.1" 200 19
    


Answer: How long is the request taking before you get that error? Google App Engine
cuts off requests that take longer than a certain number of seconds (that
"Deadline exceeded" error, see the
[docs](https://developers.google.com/appengine/articles/deadlineexceedederrors)
for more info).

You'll probably need to move the uploading step outside of the web request.
Here are three methods GAE gives you for doing that:

  * Scheduled tasks (cron): 
    * <https://developers.google.com/appengine/docs/python/config/cron>
  * Task queue: 
    * <https://developers.google.com/appengine/docs/python/taskqueue/>
  * Background threads: 
    * <https://developers.google.com/appengine/docs/python/modules/#Python_Background_threads>

