Posts

Showing posts with the label tornado

The sever send SYN/ACK after receive SYN from client immediately

The sever send SYN/ACK after receive SYN from client immediately I found the request from client timeout sometimes. And I use tcpdump on the server side to catch some special tcp packet as follows. It seems no packet was lost. Why the server doesn't reply to client after receiving the first SYN? enter image description here netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' SYN_RECV 220 CLOSE_WAIT 1 ESTABLISHED 496 FIN_WAIT1 42 FIN_WAIT2 2 TIME_WAIT 72588 sysctl -a | grep tcp net.ipv4.tcp_abort_on_overflow = 0 net.ipv4.tcp_adv_win_scale = 1 net.ipv4.tcp_allowed_congestion_control = cubic reno net.ipv4.tcp_app_win = 31 net.ipv4.tcp_available_congestion_control = cubic reno net.ipv4.tcp_base_mss = 512 net.ipv4.tcp_challenge_ack_limit = 100 net.ipv4.tcp_congestion_control = cubic net.ipv4.tcp_dsack = 1 net.ipv4.tcp_early_retrans = 3 net.ipv4.tcp_ecn = 2 net.ipv4.tcp_fack = 1 net.ipv4.tcp_fastopen = 0 net.ipv4.tcp_fastopen_key = fc1980cc-2a3369bf-91223671-bb8e...

ModuleNotFoundError When loading a pickled file in tornado

Image
ModuleNotFoundError When loading a pickled file in tornado I am using tornado framework for loading my machine learning model. I have a popularity class import numpy as np import pandas as pd from pandas import DataFrame class Popularity(): users_data = pd.read_csv('~/Desktop/LatentCollaborativeFiltering/lib/seed_data/ratings.csv') movies_data = pd.read_csv('~/Desktop/LatentCollaborativeFiltering/lib/seed_data/movies.csv') data = pd.merge(users_data, movies_data, left_on="movieId", right_on="movieId") data = pd.DataFrame.sort_values(data, ['userId','movieId'],ascending=[0,1]) def __init__(self): pass def favoriteMovies(self, activeUser,N): topMovies=pd.DataFrame.sort_values(self.data[self.data.userId==activeUser],['rating'],ascending=[0])[:N] # return the title corresponding to the movies in topMovies return list(topMovies.title) def recommend_movies(self): re...

How to Distinguish Button Presses in Tornado?

How to Distinguish Button Presses in Tornado? In the process of teaching myself how to use python's tornado web framework, I am trying to create a simple web server and some web pages. On one of the web pages, I have two buttons: one to log users out and redirect them back to the login page and one to submit a blog post. They are both "post" requests and have their name values in html set to "logout" and "new_post". My questions is, how can I tell which button was pressed so that the post() method for the page's RequestHandler can perform the correct actions in each case? Is there a way to grab the "name" of the button pressed? 2 Answers 2 When you submit a form with a button click, a parameter with the name of the clicked button gets added to the request. You can check, if the parameter exists and then do your stuff. def post(self): if self.get_ar...