0

I have a piece of code that does not run but I do not know why.

It fails somewhere in the library but it seems there is no error thrown so I do not know what goes wrong:

the pseudo code:

print('test')
try:
    df = DeltaTable('mydata/').to_pandas()
except:
    print('test2')
print('test3')

So I would expect to get either test and test3 as an output or test and test2 but I am only getting test

Is there any other way to get/catch whatever is going wrong in the library?

user180146
  • 895
  • 2
  • 9
  • 18
  • Remove the `try except`. – Guy Jul 04 '22 at 08:21
  • I had that first. It only prints the `test`. I had hoped to catch something with the try except but no luck – user180146 Jul 04 '22 at 08:22
  • There is no way the snippet you provide to not print `test3`. Probably there is infinite loop in the try block? – buran Jul 04 '22 at 08:23
  • Why do you think is "crashes"? Does it say anything on the screen? Does it hang? – doctorlove Jul 04 '22 at 08:24
  • no nothing happens, it just seems to be finished. But as @buran mentiones than I expect to see a print `test3` – user180146 Jul 04 '22 at 08:25
  • Replace the except with `except Exception as ex:` and debug the code, see what is getting catched. – Guy Jul 04 '22 at 08:26
  • Is there possibility of infinite/long-running loop in the `try` block? – buran Jul 04 '22 at 08:26
  • @Guy, note that they also don't get `test2` printed, i.e. it is not clear that the code enters the `except` part either – buran Jul 04 '22 at 08:27
  • @buran The OP could easily missed one word in the output. And even if he saw it, it wouldn't mean anything either than there was an exception. – Guy Jul 04 '22 at 08:29
  • @Guy I tried that and it does not seem to get in the except block. The library code is basically reading a lot of data, I have tried the same code with a smaller dataset and that worked. But for this bigger set it does not. However the data is not mine so there might be more differences between the two datasets than just size. Thats why I would like to find out what goes wrong inside the library. Is it memory? Or something else? – user180146 Jul 04 '22 at 08:31
  • Please, post [mre]. – buran Jul 04 '22 at 08:32
  • @buran that is not possible because it is probably dependent on the data being read – user180146 Jul 04 '22 at 08:33
  • @user180146 Maybe it just take a long time? anyway it seems unlikely the program just stop in the middle without any errors, post the full code you are using and the data causing the problems. – Guy Jul 04 '22 at 08:34
  • @user180146, that's the point of [mre] - provide enough of code and sample data that **reproduce** the problem. Most likely OP will find what's going on while creating the example. Without [mre] we can only guess what is going on, and based on OP description - nothing wrong is going on, code is running in the try block and hasnot finished execution. – buran Jul 04 '22 at 08:35
  • @buran Guy. It is not my data to share, so that is impossible. I will edit my question somewhat. I mainly want to know if there are other tricks to catch whatever is going wrong other than an try except block. I know it finished because my terminal tells me so and I know it crashed because there is no `test3` or `test2` – user180146 Jul 04 '22 at 08:37
  • Then the only possible explanation is that `print(test3)` indentation is off, i.e. not what you think/show in this snippet, maybe it is inside the except block or inside some if that does not run, etc. As to confidentioal/proprietary data - you can provide dummy data – buran Jul 04 '22 at 08:51

0 Answers0