« first day (3848 days earlier)      last day (1325 days later) » 

00:00
It's "name mangling" and it has work-arounds
encapsulation is a concept, not a protcol
and python is not very good at it
hm, is there a similar bookmarklet for RLemon's snippets for SO comments on questions?
00:38
cbg
new around these parts qwert
anyways guys, I'm trying to use dataclasses and I just cant figure out my post_init isn't getting called. What I'm doing:
If you have a problem, try asking in a question?
oh never mind, im just a sleep deprived idiot
was calling __post_int__
00:55
i believe we call this an error in the interface between the chair and keyboard
cbg room 6 :)
01:13
I still cannot find a good reason for list.index() to not return a list of all the occurrences of the item.
@CoolCloud lot of performance loss for very rare use cases
Python insists on a lot of complexity for very rare use cases
You could try suggesting new syntax for it. lst??val perhaps.
01:31
@AndrasDeak ??
why not just have your own loop for that?
01:48
I mean we could. But felt like python really don't care about 'ties'. Like the discussion we had a few days back
Trust me, that discord server is a FISH MARKET. Everyone asking for help in different channels. Alot of people helping and explaining. Very unlike SO. No need attempts. Can ask for opinions, bla bla
02:28
I visit the discord server at times, gave up hope when a guy I helped told me my solution was not a recursive one because it only had one function call in it :/
 
3 hours later…
05:01
@python_user lol
 
2 hours later…
06:50
morning cabbage
I like how everyone just wakes up and comes to room 6 for cabbages :D
07:01
a cabbage a day keeps the drudge away
07:37
yes, cbg :)
@python_user it's an interesting breakfast :)
08:55
wait django uses jinja2 right?
I get: django.template.exceptions.TemplateSyntaxError: Invalid filter: 'round' for {{x|round(2)}}
Not sure, after googling
> Jinja is a modern and designer-friendly templating language for Python, modelled after Django's templates.
haha, hahaha, that's how I felt too, but it's floatformat
im about 75% sure django uses it's own templating engine
09:13
how do I change this line: @app.route('/driveStatus', methods=['POST', 'GET']) to work with FastAPI syntax?
cbg
yeah... you can use different template engines in django but since the existing one is so widespread... it's just a right yam to do so :(
10:07
@rel.foo.fighters my google search lead me to double decorating them, does that work?
@app.get()
@app.post()
def foo():
    ...
10:49
@Hakaishin no, it doesn't. You might be able to make it use jinja2 but by default it's a different templating language
11:00
@python_user Yes you are right :)
11:12
Today my pet peeve is that my PILlow-facing code crashes with the cryptic SystemError: tile cannot extend outside image rather than something plainly descriptive like "0x0 images can't be saved as a png"
Maybe they can?
I haven't totally ruled out the possibility. I don't see it explicitly forbidden in the spec*, although I only gave it the most cursory of skims
(*... Ok, the Wikipedia summary of the spec)
Today I am annoyed that PILlow might be refusing to save a perfectly valid 0x0 png
I'm experiencing a whole new type of inner grief as I've just gone back to one of my old code bases that got passed on to someone else and my SQL is being extended by use of format. This is despite the fact that the bits of the query I wrote use parameterization quite clearly, still. :'(
"Width and height give the image dimensions in pixels. They are PNG four-byte unsigned integers. Zero is an invalid value." -- w3.org/TR/PNG/#11IHDR
Ok, never mind, I'm not annoyed about the second thing.
I assume this is fairly typical for image formats. MS Paint refuses to let you make a 0xN or Mx0 canvas, let alone save one.
"Bitmaps must be greater than one pixel on a side", it says. I wonder if this implies that it represents image data in memory as .bmp format, and only converts if you save as something else? If it was just using "bitmap" in the generic "2d array of pixels" sense, then it should be perfectly comfortable allocating a 0 size array.
I have a problem, but the code associated with this is huge (lot of files).
How can i make a minimal reproducable example?
Can i make an exe application and post a google drive link?
11:25
An exe wouldn't be useful to us, since a good MCVE needs human-readable source code
i feel like you've misunderstood the point of a "minimal" reproducable "example"
I can describe the problem here in a few lines.
that would still not be a MCVE.
If you can describe the problem in one message (multiple sentences allowed), then I'm interested in hearing it even if you don't have an MCVE yet.
but we could try a description if you wanted. just with the fair warning that there's a good chance if the description doesn't help solve the issue, we'd end up where we started
11:26
yes
@Kevin I have a preview sound file/clip PyQt5 Gui, which is uses pyaudio.
I have two button, which is in the same window and when are clicked some database stuff is done.
The problem is when i click the buttons, for ~1 or 2 seconds, the pyaudio sound is paused.
Let's say 1-2 messages, since I often run over the max character limit myself when describing problems
So it's a multi threading stuff
Interesting. if pyaudio lets you play sound asynchronously, I wouldn't expect it to pause just because a thread becomes busy
I tried:
1) QTimer
2) proccess
3) threading

Nothing worked.
11:32
Unless pyaudio expects the GIL to regularly wake up its sound playing thread, and it can't do that when the database is doing heavy I/O
Note: I think is a python/sqlite3 issue.
Because in another page i have a search window. When the user clicks search, in the top of the code a start a loading gif QMovie and then i search in the database.
But the QMovie doesn't animate until the database stuff is done.
Maybe, if i "migrate" to MySql the problem will be solved.
Yeah, it's probably sqlite3 hogging all the processor time. I'm not optimistic that MySql will do much better.
But it could be a most educational exercise to write two little programs that compare sqlite3 against MySql and see if both of them hang in situations like these, so maybe try anyway
When you tried process, what were you putting in the subprocess? The database logic?
Also, when you say "process", do you mean multiprocessing or subprocess or something else?
Hmm, i am not really remember.
multi...
So, i will try with mysql, and if it works, have a nice Easter!!
If not, have a nice Easter too.
:-)
11:41
If MySql also causes the program to freeze, it may be worthwhile to try the multiprocessing design again. If the problem is GIL-hogging as I suspect, multiprocessing solves this by giving separate GILs to the database process and the main process.
does any one knows how to handle fastapi errors?
I wonder if Popen.wait occasionally yields control to the GIL... I suspect it does, since the docs says it sleeps periodically
I have code which working in flask, but when I'm moving to fastapi the call fails with error 500
I guess in the worst case scenario you could simply write a custom sleep-and-poll loop yourself that respects the GIL
@rel.foo.fighters I expect they can be handled much like the errors of any other framework.
The thing is I don't understand how to debug fastapi
11:46
Do you have any information about the error besides "HTTP 500"? See if there are any logs saved, they may have a stack trace
usually there might be useful messages being dumped to the terminal that fired the server
Yeah. If you're running the .py script directly, I'd expect a stack trace right there in the console window
I see fastapi's documentation mentions something about "global exception handlers", those sound like they might be useful if you need to hook up logging manually
ValueError: [TypeError("'property' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')]
Progress!
If you are using @property decorators (or similar), and if you're calling vars() somewhere, these should give you some useful hints about where to look.
If not, getting it to print the stack traces, complete with filenames and line numbers, would be useful
12:04
I don't have in my code anything with property or vars :)
You'll definitely want those stack traces then.
traceback.print_exc() might be useful here, depending on whether you can execute code after the error occurs, and if there's an except block executing somewhere on the call stack. It's worth a try.
I have a nagging feeling I'm over-complicating this, but you get what you pay for ;-)
FastAPI has some guide on handling exceptions well. Might want to take a look.
Wisdom
tnx. I will have a look
12:19
Googling "vars() argument must have __dict__ attribute" fastapi turns up one hit for me, and it's in Japanese... The rare DenverCoder phenomenon variant, KyotoCoder
The accepted answer recommends that you こっちも一緒, hope this helps
same here :) very usefull
Well I guess it's nice to know there are at least two other people with the problem.
meanwhile, can you recommend on easy swagger flask I can use to create swagger form current code?
The code is in English, so maybe looking at the site will turn up some clues anyway. bleepcoder.com/ja/fastapi/681860711/…
I don't know what swagger is so I don't think I can recommend anything :-)
sounds too complex for simple issue. tnx, I will try to dig in more
12:28
hello
gm to those in my timezone
man things interface together by just the name is so bad. I just changed the name of something and things broke, luckily I remembered that ros works this way, but it's a really flimsy way to communicate
and not name in the sense of var or object name or something, but literally super().__init__(name="foo_client")
from foo to foo_client broke it
I occasionally use something like name=foo_client.__name__ to get better errors when refactoring.
When I need to interface by name, I at least try to make them constants rather than literals, so it's more obvious to the reader that they shouldn't make inline changes lightly
If you change super().__init__(name=FOO_NAME) to super().__init__(name=FOO_NAME + "_client"), it's not as much of a surprise when it fails
And if I've abstracted things properly, changing FOO_NAME = "foo" to FOO_NAME = "foo_client" shouldn't break anything, since both ends of the interface are using that one object
At that point it's basically just a sentinel value with a nice printable representation
12:55
@roganjosh use the injection vulnerability to edit the files on disk
Hmm, I guess sql is not powerful enough for that
Drop table customers it is :P
@Kevin Good idea for next time. Now I just added a comment
Funny enough I wrote that part a few weeks ago :P
13:18
anyone know how the leagues work?
i've been trying to understand but it's weirdly confusing
Never heard of it.
@Kevin that's why you're medium league. Git gud.
I'm #32068 in quarter... but i'm so confused as to how this works
Tough love
13:21
exactly 1K people have 100K+ rep
There's like a 0.1% chance of that number occurring naturally, which isn't too unbelievable
The period of time where any 1,000 people have a constant rep total would be short I'd think
@Dodge it's all time
but exactly 1K seems too smooth 🤔
Apply a fudge factor to account for the fact that you would have noticed a round number in any of the 11 tiers, and that people just below 100K rep may have tried extra hard to become the thousandth 100K user, and lost interest after someone else got the slot
Oh 100k +, oops
If I see anyone with 99,999 rep I give an upvote just because
13:28
@Kevin i upgrade to mysql.
The problem consists and now the pause time is bigger (from 2 seconds to 7 seconds).
Sorry to hear that. I'm becoming pretty certain that GIL-hogging is part of the problem.
2 hours ago, by Kevin
If MySql also causes the program to freeze, it may be worthwhile to try the multiprocessing design again. If the problem is GIL-hogging as I suspect, multiprocessing solves this by giving separate GILs to the database process and the main process.
What the multiprocessing will do? PyAudio or Database insert ?
Database would be better, since it's the thing using up the most processing time.
ayyy lol
ugh
@12944qwerty can you do this elsewhere?
go on tiktok or something
13:32
lol
it looked like a question but it was actually a request
5/7 yaks shaved... Now I need to take my jaggy 2d array of recognized text and give it a sane structure
@Kevin yakky
yo kevin, i'm attempting at making the bookmarklet on the idea i had yesterday, but I'm stuck since it's not working... can ya help?
it's in sandbox btw
13:48
Yeah
14:13
@Kevin I used QThread and now works. But after the db insertion i want:
1) Call a method from main window that updates a QTableWidget
2) Display a QMessageBox to inform the user that the insertion has been done.
Any way, maybe i may use qsignal, but i am not familiar to this.
Perhaps you could use a multiprocessing.Queue to send messages from the database process to the main process. Once the database process completes the query, push all the data you want to display on the queue. In the main process, the GUI should periodically check to see if the queue is empty. If it isn't, use the data to update the table, and then display the QMessageBox.
I wonder how the queue transfers objects between processes. Json? pickle? dark magic based on memcpy? Depending on what you're doing, you may need to convert your data into collections of simpler types before putting it in the queue.
late morning cabbages, folks!
So like a list of strings rather than a DatabaseRowItemCollection of DatabaseItemVarCharValues, or whatever
@Kevin pickle over a pipe or socket
Ok, cool. So you miiiight be able to send a DatabaseRowItemCollection, if the developer was nice enough to make it pickleable.
14:28
That's why lambda and other unpickle'able things can't be passed to processes.
In my day job, my ORM is not nice enough to make its query results easily serializable -_-
Gosh, I've spend about two hours writing docs to explain recursion for matching a sequence of "a"s. Hopefully this thing will never catch on...
ahh, but dill claims to solve exactly that problem
PyPy also can pickle most things out of the box.
Hmm! dill can serialize whole interpreter sessions. I was just thinking the other day if that was possible.
14:33
Some things not being supported by pickle are frankly just "it didn't hurt anyone badly enough to add support for it".
FWIW, most things can be sent to subprocesses by just pickling their code and attributes.
With the power of dill I will finally implement call/cc in Python
Future generations will hail you as their saviour.
Hey everyone :) I want to convert a timedelta into regular English. Examples 02:00:00 becomes "2 hours", 02:00:10 becomes "2 hours and 10 seconds" and so on. I feel like I've used this before and it was part of the stdlib, but now I can't find it anymore?
Or am I mistaken?
I use Rapptz version on his discord bot.... 🤔
14:49
@finefoot Googling for "python timedelta human readable" turns up a number of promising leads, including the humanize package
I think this would be a fun project for a beginner-verging-on-intermediate.
@PaulMcG Yes thanks but nothing from the stdlib. So it seems like I was wrong
It's nice that the data I'm scraping shows all the numbers it's multiplying, and the final product of those numbers, since I can basically use the product as a checksum for my image detection. The only problem is, it thinks that 1 * 6 * 1.4071 equals exactly three.
It is almost certainly flooring the product to a maximum value, but it varies between data sets. The majority of them top out at 3, but some go higher, the worst offender going up to 7.5.
15:07
@Kevin - agreed.
parts = [' '.join(t) for t in zip(delta.split(":")[::-1], "seconds minutes hours days months years".split())][::-1] and ', '.join(parts[:-1]) + ', and ' + parts[-1] gets a human readable timedelta
I wouldn't call that human readable at all
@Kevin Sounds like you are describing handcalcs, a plugin for Jupyter Notebook that expands expressions into pretty textbook-like output.
I think he means that the subject of his OCR says "1 * 6 * 1.4071 = 3`
Yeah. In other words, I'm lamenting that I can't double check my scraped data against the original source's, because the algorithm it's running on its inputs has details that are unknown to me.
I can make educated guesses, like "if the result is an integer or a fraction with denominator 2, it was probably floored", but that reduces the number of true ocr failures that the validator can detect
15:15
@inspectorG4dget is that first and a Python and or English "and"?
@python_user the first one is English. The second one is Python. Markdown code formatting in chat isn't sufficiently clear in this case, it seems
If the original source says "10 x 23 Million == 3" and my OCR reads it as "10 x 23 Billion == 3", I can correctly deduce that the expression has an implicit floor-to-three step, but I can't programmatically detect that my OCR got the second number wrong
or that the 3 is correct
you might be able to, if you knew the source font and tried to render the OCR'd text into an image with that font and then compare the two images
@Kevin I tried to use multiprocessing Queue with no success.
Here is what i have done:
1) In main window programm i import `from multiprocessing import Process, Queue`
2) Then when i call the db thread i pass the queue instance as parameter.
3) When db is ready then i call `self.update_player_list_queue.put("update-player-list")`
4) Then i have this code:


`while(True):
			try:
				item = self.main_self.update_player_list_queue.get()
				if(item=="update-player-list"):
					self.main_self.display_player_list_items()
15:18
Good idea. But I don't have much of an eye for fonts, alas.
@inspectorG4dget I got my head wrapped around this, for an one line experience parts = ', '.join((_:=[' '.join(t) for t in zip(delta.split(":")[::-1], "seconds minutes hours days months years".split())][::-1])[:-1]) + ', and ' + _[-1]
I think I shared a screenshot of my source image, where did I put it...
Here it is. i.sstatic.net/kOzKP.png. Maybe some sharp-eyed reader can figure it out.
@Kevin I wonder if there's an OCR engine to font-detect
I know there is, and I tried using it in the past on a different project, with... Mixed results.
May as well try again, if I can find it a second time
There's a superuser post on this. More to the point, since this appears to be a singular application (i.e. you're doing this for your one game, and not looking to scale this across all fonts), you might be able to get away with a non-API clicky-clicky soluiton
also, what game is this? Catan?
15:23
NGU Industries.
I'll try simply picking the first font identifier site off of Google, www.myfonts.com. It does a very good job of detecting text in my image, and it returns about 30 possibilities that all look quite similar to the game font, to my untrained eye.
I'm skeptical that just picking one at random, or even the top listed one, will give me something that I can usefully use to validate my OCR'd text. If the imitation font is just a little wider than the game font, for example, then the threshold matching approach I've been using would give their comparison a poor score on medium-to-long inputs
If the two renderings of "I've got a lovely bunch of coconuts" gradually diverge so that the imitation's final T lines up with the game's final S, the comparator would say "these don't look anything alike! F Minus"
Create your own font from the templates?
kerning would strike again :P
You may be thinking "so drop your existing matcher and use a more scale-agnostic one". But, you see, I am very tired...
@AndrasDeak I know, I'll train a neural network to generate the font, and as the input data I'll use my OCR'd text. Then I can use the neural network to verify that my OCR'd text is correct ;-p
you already have a neural network to do the OCR, it just doesn't want to work on it
Darn biological hardware! Maybe a little percussive maintenance... [thump]. Ow! No, that didn't help.
@Kevin have you tried turning it off and on again?
:)
15:34
We can't turn Kevin off; we'd all disappear.
I've done thousands of soft reboots to sleep mode and back. A hard reboot would void the warranty.
You would not believe how troublesome it is to spin up the system from a zero power state
I, too, could joke about this without crushing existential dread.
I'm always in existential dread, I have become stronk like deepsea fish
But if I ever return to zero crushing, I will become a blob creature. Leave me down here, I have made a comfortable life given the circumstances
Actually as of late I think I've migrated from cheerful nihilism's "nothing matters and the throne of heaven sits empty, so let us create our own purpose, and heaven with it" towards a more primitivist "I don't know if anything matters, and don't care, do you want to go ride bikes?"
The outcome may end up the same, if mankind's constructed heaven has bikes.
you /could/ segment both images and sequence match to get around the kerning problem
Microsoft teams doing a stellar job as usual
15:49
@Kevin It probably has. But if the bike asks you to accept an EULA you got the bad ending.
@Kevin don't be a blob creature... become Sloth from The Goonies... We'll make sure you get your candy bars! :p
@Kevin modern-day "Re: Re: Re: Fwd: Re:"
I might be able to pull off a Sloth, if I don't decompress too fast. Could be a fresh look for me too
Cbg guys
Been carried away recently by that discord server
@inspectorG4dget True. I'll spot-check a couple more of my input images and assess whether I really want improved validation.
15:56
Sounds like the yak farm is in full swing
@Kevin i am really confused.
Rather this worked: https://realpython.com/python-pyqt-qthread/
Oh? interesting. I wonder if QThread has some special technique to enforce more cooperative processor sharing.
I don't see anything obviously wrong with your code at chat.stackoverflow.com/transcript/message/52095930#52095930... Although I am concerned that you mentioned the "db thread". Try not to use threads and processes at the same time, because it's hard to juggle both and get everything to cooperate properly.
I know it might seem like a pain to use only processes, because compared to threads it's a lot harder to share objects between processes. But if it fixes a performance bottleneck, it can be worth the suffering
Or just don't bother with it at all, if QThread fixes the problem :-D
Hmmm, in python does it actually read the RHS first and then execute it and then assign the value to the LHS, like
```
f = 'hello'
f = f.title()
```
@CoolCloud make a situation when both sides raise an error and see what happens
@CoolCloud 1. there's nothing ambiguous going on there, 2. how do you not know how to format code here?
Its the theme, It does not let me add ctrl + k, smh!
16:09
mhmm
There's also a "fixed font" button you can press that does the same thing as ctrl+k. (It only appears when your message has more than one line)
and there's the sandbox for practice
If you're curious about the order of execution of the parts of a statement, you can see all the grisly details using the dis.dis method. For example:
>>> import dis
>>> dis.dis("x = 23 + bar()")
  1           0 LOAD_CONST               0 (23)
              2 LOAD_NAME                0 (bar)
              4 CALL_FUNCTION            0
              6 BINARY_ADD
              8 STORE_NAME               1 (x)
             10 LOAD_CONST               1 (None)
             12 RETURN_VALUE
What is dis ;-)
New phone who dis
It's short for "disassembler" and that's just what it does.
16:12
So first it loads the name? then it calls the function
What does the 0 and 1 mean?
I believe those are the indices of the objects in the secret invisible variable list that every Python scope has.
So it only stores towards the end right?
23 is the 0th constant, bar is the 0th variable, x is the 1th variable, None is the 1th constant
the 0 next to call_function is outside of my realm of knowledge. Random guess: "execute the 0th element of the stack as if it were a function"
@CoolCloud Right. instructions 0 through 6 are all the RHS stuff, and 8 is where it assigns the value to x.
Hmmmmmm this is really some useful stuff, thanks mate.
Even if you can't comprehend 90% of dis' output, it can still give you some interesting tidbits. Speaking from experience.
I wonder why that disassembly has instructions after 8... It looks like it's returning None, which is what a function always does if you don't return something yourself. But the input I sent to dis isn't a function.
I don't think that dis always assumes that a naked statement is inside a function, because dis.dis("return 1") crashes quite reasonably with SyntaxError: 'return' outside function
... Does the file-level scope always have a secret implicit return at the end? I guess that could theoretically be useful for the import mechanism...
16:25
@Kevin return in a non-function?
I know, sounds crazy right?
It looks like code objects always return something.
Which kinda makes sense, since any code evaluates to something.
Modules aren't themselves code objects, right? That would ease my mind
Any runnable code, including the module body, is executed as a code object.
Ok, cool. I think that answers the question as it existed in my head.
16:30
tugs away the crystal ball
[appreciative golf clap]
@Kevin I post a question here: stackoverflow.com/questions/67321466/…
I am just 1 point away from getting silver badge on tkinter. Useless excitement
@ChrisP Cool. If I come up with more specific advice than "try using multiprocessing", I'll give you a ping
My knowledge in that field is largely theoretical which is why you haven't seen any actual code from me :-)
17:04
cabbage
 
1 hour later…
18:07
The term for anything in python that exists without needing to be defined is "built-in"? I'm teaching my daughter to code and trying to explain why she does not need to define 1. I said "it's an integer and the interpreter already understands what it is,,,". But ints are not built-ins are they? I there a better term here?
@Dodge ints are built-ins, but 1 is a literal
>>> import builtins
>>> builtins.int is int
True
int is a built-in so you can also do int(input()) without having to define int nor input anywhere. Both are built-ins.
@AndrasDeak ah, yup, the int() function complicates that. Thanks. "Literal" is helpful as well
When you actually try to explain some of this stuff to a child you realize how much you don't know. Basic stuff much of it.
yeah, it's very hard to convey intuition
cbg, all
cbg
18:25
cbg
@Kevin On the off chance that you haven't discovered this Youtube channel yet... you might enjoy this guy's videos
19:06
Code added: https://stackoverflow.com/questions/67321466/audio-stream-paused-for-some-time

Vote for re-open please.
19:42
Hi there. I have a bash shell, where echo $FOO returns the expected result. Running python3.8 manage.py migrate (yep, Django) yields NONE at os.getenv('FOO'). Why is that?
@tjati FOO is probably not an environmental variable, just a regular bash variable?
try env in your shell and see if FOO is in there
Yup. Are you exporting FOO?
env |grep FOO
20:00
@AndrasDeak I wonder if there's a way to fire a warning shot across the bow
Which meaning of "the bow" is this?
I sunk your battleship
So I'm thinking flaming arrows...
Ah, sorry, I think I misinterpreted your question's weighting. It would be easier to plot a warning shot if they weren't also re-writing my app into Shiny and trying to call into Python
This is fine. Everything is fine.
Is it your responsibility?
20:10
Well, I have to be in the meetings
sounds like that's the part you need to fix. ha
But... it's my baby. I wouldn't leave it out for it to be ravaged :/
hm..tricky tricky
That's actually an overstatement. Of my many coding concerns, this really doesn't rank highly... but the misuse of SQL does
20:16
that one should be easier to tackle no? just find the scariest sql injection article that exists and dump it there
i suppose i'd talk fancy words like say, code review..but heck, they dont even exist where i work so :P
But do you have an experience named after yourself? Apparently I do.
oh i didn't understand that sentence at all
what does "named after yourself" mean?
Given that my surname was often reduced to "Pilko" in school - there's seemingly an event of "being Pilko'd" going around at work
yeah? what is it?
rofl! and what does being pilko'd actually imply?
20:21
Being told the truth?
ah, nice
you can definitely use that then
youve got the bow and arrow, fire away!
(and now that i finally can re-read your sentence and make sense of it, no i dont have an experience named after myself. not cool enough for that i suppose :P)
i mean, half the people would probably get my name wrong if they tried
if an experience were named after me it would not be a pleasant one :P
You don't have to be cool for it, just volatile enough
In soccer deaking is juking or faking, also in hockey
Oh im very volatile...in my mind, in make-believe interactions that never actually happen.
20:24
@ParitoshSingh is it said like "sing"?
@Dodge nah, surname is fine, but you just got "singed" wouldnt be...actually...i take that back, that might kind of be cool
I'm saying the first part of your username right in my head, i think
@ParitoshSingh there's always an xkcd xkcd.com/337
but my surname is common enough that it won't really tie to me
@AndrasDeak well i'll be darned!
Hi
I have a question on flask python
20:35
Shoot
I created app with python flask code. it runs with Python 3.9.4
I was able to test all the POST and GET methods locally
Then I tried to do the same but this time from Dockerfile on top of AWS instance
I'm using python:3.8-slim-buster
but when I'm trying to test my curl commands, I get these exception: TypeError: Object of type HTTPError is not JSON serializable
So, nothing to do with Docker
correct
but why the behavior is different?
Ok, but you set it up that way as a question. You need to see what the error code is and the message
Are you using requests?
20:43
In which case, I'm going to guess that you're calling .json() on the response. What do you get with print(response.text)?
I see one thread related it
398
A: json.dumps vs flask.jsonify

Kenneth WilkeThe jsonify() function in flask returns a flask.Response() object that already has the appropriate content-type header 'application/json' for use with json responses. Whereas, the json.dumps() method will just return an encoded string, which would require manually adding the MIME type header. Se...

I will try to do the replacement
There is no "try", only do. But I think I'm getting confused now too with what you're asking
You need to show the code at this point. It looks like you're trying to interpret the http status code as JSON, which will be broken in every case
Also, my Yoda quote was both obscure and underserved on my side. It would be helpful if you ca give the exact error
Currently, my function returns return response.json()
It probably shouldn't do that because it gives you no chance to catch this error. In any case, I guessed that issue, but I can't guess further down the chain
21:16
my code is:
`@app.route('/v1/api/checkCurrentWeather')
def check_current_weather():
try:
location = get_location_by_ip(IP)
city = location['city']
country_code = location['countryCode']
temp_celsius = get_celsius_degrees_by_city(city)
except Exception as ex:
return {'message': 'FAILURE', 'ex': ex}, 500

return {"city": city, "country": country_code, "degrees": temp_celsius}, 200`
def get_location_by_ip(ip):
url = f'{GEO_IP_SERVICE}/{ip}'

response = requests.get(url)

response.raise_for_status()

return response.json()
my main question is why it behaves differently in my local against my container?
21:36
mmm, well I watch ShinyProxy destroy my code all the time
I'm not saying that's the issue here, but I really don't want another headache so I'm probably out
return response.json() is still broken and I did ask you a question + gave you a suggestion around this that you haven't taken on board
what do you mean broken?
I don't even how to debug it as it works locally.... it happens only on the AWS instance
Well it'll blow up and you just assume things can be deserialized from JSON... even though you know you're getting an error in this arena because that's the root issue
@rel.foo.fighters At this point I don't believe AWS is the factor
ok got you
I dig in the error and I can see the issue
21:49
@rel.foo.fighters I asked you a question related to this: chat.stackoverflow.com/transcript/message/52098225#52098225 but you didn't answer it
22:08
@holdenweb Thank you. That was helpful!
 
1 hour later…
Anonymous
23:23
Hello!
Anonymous
Exceptions in my worker thread's are hidden. How can I deal with that?
Anonymous
I want to see the exceptions
Anonymous
23:51
How come my daemon thread continues after having an internal exception??
@SinkingTitanic please save the random off-topic questions for when you'll have valuable contributions to the room

« first day (3848 days earlier)      last day (1325 days later) »