On a fairly classic Pyramid app (sync, gunicorn, SQLAlchemy / Postgresql, 
like the starter template), I am storing analytics-like events in a table 
for some of my views.

Like this skeleton:

@view_config(route_name='test', request_method='POST', renderer='json')
def test(request):
    # body of the view
    map_id = request.json_body.get('map_id')
    data = {...}
    
    event_data = {'action': 'viewed'}
    event = MapEvent(user=request.user, action=event_data, map_id=map_id)
    request.dbsession.add(event)

    return data



My problem is that while 99% of the views make read-only requests to the 
database, and thus are very fast, the analytics event is a writing and can 
be slow occasionally. 

Would it be possible to somehow send the request to the client and still 
keep processing the view? Like a send() + end() method or something 
similar, without returning?

// Adding to a tasks queue is not an option as it'd be an overkill and an 
overcomplicated solution, which wouldn't work for hundreds of thousands of 
events per day. 


-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pylons-discuss+unsubscr...@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pylons-discuss/c44e1af6-8c30-478e-9baf-d7fd8c93e0b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to