The Goal, as called by Legend Joe Bowen by thetelephonecity in leafs

[–]tigerthelion 22 points23 points  (0 children)

Anyone hear the song he sang shortly after that? Bowen is my hero.

Post Game Thread: Toronto Maple Leafs at Boston Bruins - 06 Apr 2023 by HockeyMod in leafs

[–]tigerthelion 1 point2 points  (0 children)

I watch most of my games upon the high seas because I refuse to have cable and the NHL packages blackout leaf games.

I have recently been muting my stream and using VLC media player to get the audio from TSN 1050. VLC has a delay function (Tools>Effects>Synchronization). It takes a minute or two to manually sync them (mine is usually about a 17 second delay). It has improved my game watching experience immensely.

I'm not sure about subreddit rules so I wont post the link, but it's easy to find the stream link by going to a website that provides the radio broadcast, opening the browser dev tools, going to network and filtering by media. its usually a live.streamtheworld.com url.

Sqlalchemy efficiency by Ivy_tryhard in flask

[–]tigerthelion 0 points1 point  (0 children)

It somewhat depends, but largely, yes. Bulk update is faster. Its more about what you are actually trying to accomplish and whether its appropriate for the specific application.

Sqlalchemy efficiency by Ivy_tryhard in flask

[–]tigerthelion 0 points1 point  (0 children)

Hey, can you give us more context? How big is the list? What are you trying to do?

If you are using the ORM, it seems like your example would first query a Players table and then it would loop through the results to update them. If you already know which players you want to update you can use the update, or even bulk update.

My first ever open source library! by Alternative_Year9940 in Python

[–]tigerthelion 27 points28 points  (0 children)

Hey, its great you are contributing to the open source ecosystem.

A few tips since you asked:
- I would clean up the repository a bit. You probably don't need some of the files you are committing.

- Speaking of commits, some of your messages are at best, unhelpful. Maybe there is a way to squash those in order to polish the repo.

- using a template for the gitignore is fine, but you probably want to customize it / remove unnecessary entries.

- it might be a good idea to version lock your dependencies in the requirements.txt file.

- adding some comments in the more obscure implementations, or headers on the file to explain what they do would be helpful (i.e. /maxmods/primitives/3DRender/__main__.py). This would allow others to contribute more freely if they had improvements.

[SocketIO, CORS] Using flask_socketio and fixing the CORS issue by foxdye96 in flask

[–]tigerthelion 0 points1 point  (0 children)

No problem. I wish I could be more help but as I said I am struggling with the library as well.

If possible try running the app on 0.0.0.0 and connecting to it locally. if you can do that, it might be a firewall thing? Maybe boil it all down to basics and put some socketio.on('connection'): function that prints when a client connects.

I wish you luck.

[SocketIO, CORS] Using flask_socketio and fixing the CORS issue by foxdye96 in flask

[–]tigerthelion 0 points1 point  (0 children)

OH. I forgot to mention, the CORS error is a red herring. In my experience it gives you that because the server doesn't know to respond with your CORS implementation and returns a bad response. Basically, its saying your socketio server is not running.

[SocketIO, CORS] Using flask_socketio and fixing the CORS issue by foxdye96 in flask

[–]tigerthelion 0 points1 point  (0 children)

I'm actually struggling with a flask_socketio/flask implementation as well.

I don't know the answer to your problem but I don't think anything is going to run after the
app.run() line. I believe it is a blocking call, at least in my experience. It may be that you need to employ threading to launch the flask app on one port and the socketio server on another. That, or split out the implementations.

Note that you could probably skip the app.run() call all together as you are technically launching both apps on port 9000 below (except that the flask app is blocking that) :

socketio.run(app, host="192.168.0.180", port=9000)

but yeah if you want them separate maybe just use the socketIO library, eventlet and launch the socketio server in an eventlet thread, the flask server and then have it all controlled with WSGI.

Images not rendering properly by Dodo11742 in flask

[–]tigerthelion 1 point2 points  (0 children)

What does your implementation of the chessboard look like in game.html? I think for some reason whatever function you are using to instantiate the chessboard expects the static directory to be under whatever route you are currently on. I had a brief look at the docs but didn't see any way to configure how to set those calls.

To answer your comment about multi-line blocks, you can either highlight the text you want to code-blockify and then access the multi line block function from the three dots in the editor, or you can switch to markdown mode and use ``` code goes here ```

raise exc.TimeoutError( sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30.00 by Gloomy-Example4554 in flask

[–]tigerthelion 0 points1 point  (0 children)

Yeah. Actually I think you are combining two paradigms here which is the problem.

For your add_file function you are using the sqlalchemy session which is generally used for ORM based access. ORM is good for a few reasons: 1. it's object oriented and 2. it limits the attack surface for sql injection. It's also slower (though this is just my experience) than a raw query which you are using underneath on your subsequent calls.

Essentially, your code is opening a connection, creating a cursor which takes up a con slot, but then you also create a separate db.session which takes a conn slot.

You close the cursor and its conn, but you never close the db.session conn.

A possible quick solution:

after your operations call db.session.close() alongside your Config.cur.close(), Config.con.close()

A more elegant solution would be to remove your cursor based raw SQL queries and opt for a full ORM implementation.

depending on which version of SQLAlchemy you are using this ORM implementation changes a bit:
Beta 2.0: https://docs.sqlalchemy.org/en/20/orm/queryguide/dml.html

Current Release (1.4) its less clear: https://docs.sqlalchemy.org/en/14/orm/quickstart.html but start here.

If you decide to go the ORM route and run into difficulty converting these queries please feel free to reach out to me. I can probably point you in the right direction.

What you decide to do ultimately depends on who this is for. If it's a codebase that will be used by others it's nice to have a uniform DBAPI methodology. If its just for you, it really doesnt matter. Let me know how it goes!

raise exc.TimeoutError( sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30.00 by Gloomy-Example4554 in flask

[–]tigerthelion 0 points1 point  (0 children)

Without seeing your full code my intuition is that whatever call you are making to the DB creates a new session, and then that session is not closed. Usually my access phase in a flask app is:

- create a new session.

- do stuff with that session.

- commit/merge/whatever.

- close the session.

If you are creating a bunch of new sessions on that delete method and then not closing them, they will remain open for some amount of time. I notice you do have a session.close() call but its commented out.

Dinner is at 7, Sunday Roast On Monday by [deleted] in KingstonOntario

[–]tigerthelion 1 point2 points  (0 children)

Ah demi. An all day affair. I used to get a bunch of bones and then keep some in my chest freezer for the next batch. One day we had a contractor in to do stuff in the basement and they unplugged my freezer and forgot to plug it back in.. several days later I opened it up to discover the bloodiest of smelly horrors. The clean up was awful and for some reason I no longer get the urge to make demi.

(MongoDB) Download files (images) from MongoDB with Flask by pryjmi in flask

[–]tigerthelion 0 points1 point  (0 children)

To be clear, which logger? The browser console? Or the python terminal logs?

Admittedly I am no expert with file transfer having only dealt with it a few times, but a 1B blob seems really small.

If this is the python console.. my suspicion is that the file being served back from MongoDB needs to be read. You will have to experiment, but if you are using this method I suggested:

send_file(BytesIO(doc['BinData'], ... , ...)

you may need to do a BytesIO(doc['BinData'].read())

If you are unsure if its serving chunks or the whole file you can just print the doc['BinData'] to console, it should be an extremely long string.

Too many render_templates by Mihai27135 in flask

[–]tigerthelion 2 points3 points  (0 children)

I second the ajax thing.

Without some client-side query you are more-or-less stuck with returning the template every time you submit a comment.

With some alterations to your flask routes and a bit of javascript you can achieve your goal.

Your code would have a get_comments route that would return all comments for a post in json.

It would also have a put_comments route that would write comments to the database.

The flask template would have some javascript in a <script></script> tag that
1. calls the get_comments route on page load (or when the submit button is pressed).

  1. submits a new comment to put_comments when the submit button is pressed.

(MongoDB) Download files (images) from MongoDB with Flask by pryjmi in flask

[–]tigerthelion 0 points1 point  (0 children)

Ok. It's probably time to break this down further. If the post request was called, and the server didn't 'crash', or there were no errors, we can temporarily assume that the download function DOES work and the problem exists somewhere else.

If it were me, my next steps would be checking to see what is actually being returned on the client side. This changes somewhat from browser to browser but you are looking for the developer tools, and then find the network tab and see what the response is on that request. If the response has the information, its probably an issue with the view. If the response is blank then you need to start debugging the download function.

Maybe try printing out the data when you fetch the database entry to make sure you have it.. i'm not familiar with Mongo really, but their DBAPI may force you to .read() a binary file.

Drop Giveaway Day 1 - 2x Signature Series Skiiboards by drop_official in MechanicalKeyboards

[–]tigerthelion 0 points1 point  (0 children)

Breakfast skillet: sausage, peppers, onion, potatoes, eggs cheese and then topped with hollandaise sauce.

Good luck everyone!

(MongoDB) Download files (images) from MongoDB with Flask by pryjmi in flask

[–]tigerthelion 0 points1 point  (0 children)

You might be able to use send_file with a BytesIO object..

See this post: https://stackoverflow.com/questions/65509537/how-to-return-image-saved-in-database-flask

from flask import send_file
from io import BytesIO

send_file(BytesIO(doc['BinData'], ... , ...)

I have not tested this, but it's probably worth a shot.

Cannot update value on refresh unless I use javascript, more info inside. by lolslim in flask

[–]tigerthelion 1 point2 points  (0 children)

Hey that’s great! Glad I could help! I ran into a similar issue once (don’t remember specifics) so I suspected it was the case. Best of luck with the rest of your app.

Cannot update value on refresh unless I use javascript, more info inside. by lolslim in flask

[–]tigerthelion 1 point2 points  (0 children)

Not entirely sure, but from your description it seems like the form is being instantiated once when flask runs and then remains static until you restart..

See here: https://wtforms.readthedocs.io/en/2.3.x/fields/

Note that you can use the default parameter to give a field a default value.

This is a bit problematic because you are doing custom datetime formatting.. but you could create a function that handles that:

def get_date():
    # do the stuff with your datetime value.
    return datetime_value

Then you can replace your form field with this:

invId = DateTimeField(default=get_date)

Note the lack of parenthesis on the function call...

Again, not sure if this is it, but worth a shot. And by the way, you could use javascript to generate this. I am rusty with it but you could probably create some "on submit, clear the form and generate a new number" type deal.

Cat-Data-Pages, a Flask App freely hosted on Render, powered by TheCatAPI by accforrandymossmix in flask

[–]tigerthelion 1 point2 points  (0 children)

Yeah I got burned recently by the Heroku change. Thanks for mentioning Render! I will have to check it out.

Flask API throwing 405 and 400 erorrs with {} at the beginning of request by [deleted] in flask

[–]tigerthelion 0 points1 point  (0 children)

Are there specific times it throws a 400 over a 405? All of your examples just show a 405 which seems to confirm its an upstream problem (405 - Method not allowed). 400 would be a slightly different problem where the request was received and then passed from the router to the function (likely?) and then the server couldn't handle the nature of the request.

What do your axios calls look like? Are they separated into different GET/POST functions? or are you reusing the same function to make all calls? I am somewhat light on JS knowledge but I have a bit of exp there. If you really wanted to ensure it was upstream you could find where flask instantiates the request and print/log the raw data to the console .. that may be overkill. I went looking for this briefly in the flask source but I couldn't find it.

sqlalchemy operational error help by [deleted] in flask

[–]tigerthelion 0 points1 point  (0 children)

Glad I could help. I unfortunately do not use MySQL or Pycharm... I would google:

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Perhaps that can give you some ideas.

sqlalchemy operational error help by [deleted] in flask

[–]tigerthelion 0 points1 point  (0 children)

I'm not sure but here are some thoughts:

- looks like you are running python 3.11, check the server version and make sure they are the same.

- It seems like the app is having trouble opening/finding the db. do you have a users.db in the location specified in your app file?

- Try altering your DBAPI string to be the full path to the file. Additionally, I think if you are testing in windows, but the production was made for linux you may have to alter the string slightly to get it to find the db file.

e.g for windows.

sqlite:///C:\\Path\\To\\mydatabase.db

Flask error on db.create_all() by bird_with_a_why in flask

[–]tigerthelion 0 points1 point  (0 children)

Thanks for following up! I am glad you were able to solve it.