Sporadic long response time for OpenShift gear [closed] - python

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have two Flask apps in OpenShift. Each one in a free small gear. Each one uses an own PostgreSQL cartridge. The code is quite simple: REST apps that do a query in the DB and return a JSON. The DB is almost empty and, in this test phase, they are accessed only by me and a response time recorder.
Most of the time, for both apps, the response time is ~300ms, what is great.
But sometimes the response takes much longer: 4s, 7s, 12s or even 15s. The same request taking 50X more time to return.
If these slow response requests were spaced 24h/48h I would say it's some kind of OpenShift idle policy. But they aren't. It's more like any request has a 5% chance of being a slow one, even if they are spaced only a few seconds. And if the requests are spaced a few minutes the "chance of being slow" raises for more than 50%.
Any ideas?
Thanks for the attention!

Related

TD ameritrade access token [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 days ago.
Improve this question
Good morning all, I am struggling with TD ameritrade’s authentication process, specifically the 30 min life span of the bearer key.
I have written a Python script to run the authentication process (https://developer.tdameritrade.com/content/simple-auth-local-apps). It’s partially automated, except for the pause to deal with the two step verification (which I can’t work around).
The trouble I have is that if the bearer key needs to be updated every 30 minutes, and the process script isn’t fully automated, it defeats the purpose of having a bot that can run and execute trades.
I see references to a refresh key, but not sure how to implement.
so far I have tried forums, YouTube , and reaching out to others within my network.
Any help is appreciated

Better way of excuting a always running app? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 months ago.
Improve this question
Good day.
I have a question about the correct way of implemting code that needs to run every 5 minutes.
Is it better to:
A - Inside the code have a timeloop that starts after 5 minutes, and
executes.
B - Have a script that runs every 5 minutes and executes your
application.
C - Other?
BG: This will be running on a windows server 2022, to send mail every 5 minutes if certain condations where met.
Thank you.
B.) The script is named Windows Task Scheduler and comes with permission management etc.. A Windows server admin can tell you about it.
Why?
Your app might have memory leaks (well, Python not so much) and it runs more stable when it's restarted every time.
An app that sleeps still uses memory, which may be swapped to disk and read back when it awakes. If the app terminates, the memory will be freed and not be swapped to disk.
Your app may crash and no longer do what you expect to be done at every interval
The user may (accidentally?) terminate your app with the same effect
Why not / when not?
If the time to initialize the app (e.g. reading data from database or disk) takes a long time (especially longer than the sleep time).

Could Python3 script (requests) used to get data from a website seem 'suspicious'? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Might be a silly question... I want to use a python script to get some data from a website every 10 or 20min.
I'm using:
requests.get("http://somewebsite.php")
data = response.text
to get the data, and the rest is basically extraction of values from the string etc.
I would like to loop it and make a new request to the website every 10 or 20min to get data.
Assuming I'm running this script for few hours:
Would it look suspicious to the owner of the website?
Would it in any way 'hurt' the website or is it just equivalent to refreshing the website in the browser?
I just don't want someone, somewhere think something malicious is happening when I'm just playing around learning python. The data is not even important, I just want to see if the script that I wrote works. I just figured I might ask here before running it.
Thanks for any replies in advance.
Although you don't want to do any harm, you can misconfigure the script by accident (we are just humans), generate suspicious activity and a real person might spend some time investigating your activity (I'm not kidding, these things really happen).
My suggestion is to use a testing service like https://httpbin.org/ to play with the requests library. HttpBin is actually created by the same person who started the requests library (Kenneth Reitz).

Can a Fast Computer and Low CPU Usage Still Take Forever to Execute? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've got a very nice machine to play with over at Azure. It's got 16 cores and memory up the wazoo.
Running on it is an app I wrote that does a LOT of crunching. Basically dividing up about 100,000 text documents into ngrams and creating a document index.
I recently moved this app over from a pretty small AWS instance with about 1/20th of the processing power. I couldn't even do 40,000 records without running out of memory. It took about 30 minutes to index 30,000 records.
So now, even with all that processing power, I'm still sitting here waiting 30 minutes to crunch 30,000 records. Is it just the nature of this type of process? Or am I not really taking advantage of my resources properly?
EDIT (THE CODE EXPLANATION):
The part of the app taking the most time is looping through NLTK library looking for named entities within the text of each document. I am running a loop of the 100k documents through a process very similar to this example:
https://gist.github.com/onyxfish/322906
Some stats:
Windows Azure VM
Python 2.7 (32 bit) (Enthought Canopy Environment)
Numpy 1.7.0
Stats:
If your process takes 0.3% of CPU time and takes a long time to execute, it clearly isn't CPU-bound.
If I had to guess based on the limited information provided, I'd guess that the code is I/O-bound. Write a little program that simply reads the 100,000 files and time it in the exact same execution environment. If that too is slow, you might want to consider merging the many files into few; it should improve things considerably.

Real time timer [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to Python so be gentle.
I have been trying to write a program that counts or measures events in real time. At the moment I am using the sleep command but this pause event doesn't take into account the time the program takes to run. I have read up on the datetime module and can sort of see how this could be used, but I am a bit stuck in implementing this.
In short, I want a program that counts from 0 to 100 in real time seconds and milliseconds.
Your best bet (besides Googling for help before posting a question on SO) might be to do something like this:
Note the time when the program starts. start = datetime.datetime.now()
Do your calculations
sleep until 100 seconds after start. (start + datetime.timedelta(seconds=100))
Note that this won't be perfect, since there is a little overhead involved with the steps between accessing the "current time" and going to "sleep" (e.g. subtracting "current time" from "wake-up time"). However, if your sleep precision only needs to be in seconds, you should be okay.
Repeat as needed.
If, after trying it out, you need additional help with the actual implementation of these steps, feel free to come back and post another question on that topic.

Categories

Resources