Repository: snap-stanford/ogb
Issue: Program cannot exit after executing the last line. (due to 'from ogb.nodeproppred import PygNodePropPreDataset')
Root cause: Resource Mishandling

My code is quit simple:
```import argparse
import torch
import torch_geometric.transforms as T
from ogb.nodeproppred import PygNodePropPredDataset

def main():
    parser = argparse.ArgumentParser(description='OGBN-Products (GNN)')
    parser.add_argument('--device', type=int, default=1)
    args = parser.parse_args()
    print(args)
    device = f'cuda:{args.device}' if torch.cuda.is_available() else 'cpu'
    device = torch.device(device)
    print(device)
    dataset = PygNodePropPredDataset(name='ogbn-products',
                                     transform=T.ToSparseTensor())
    print('Done load.')
    data = dataset[0]
    print('Finish.')

if __name__ == "__main__":
    main()
```

The program cannot exit after print "Finish.", when i kill it, it will show some problems about `threads`
```
Namespace(device=1)
cuda:1
Done load.
Finish.
Exception ignored in: <module 'threading' from '/home/xxxxx/Programs/anaconda3/envs/xxxxx/lib/python3.9/threading.py'>
Traceback (most recent call last):
  File "/home/xxxxx/Programs/anaconda3/envs/profiling-cu113/lib/python3.9/threading.py", line 1477, in _shutdown
    lock.acquire()
KeyboardInterrupt:

Process finished with exit code 0
```


I'm sure the ogb is the latest(1.3.5), the system is Ubuntu 20.08.

When i comment `from ogb.nodeproppred import PygNodePropPredDataset`, it can exit with code 0 normally.

Hi! Hmm I cannot reproduce this. I also used ogb 1.3.5, and I was able to run your code without any issue (Ubuntu 20.04).
I am a bit confused. When you comment out `from ogb.nodeproppred import PygNodePropPredDataset`, how did you get `PygNodePropPredDataset`? Also, given that the code is excuted until `Finish`, I am not sure if the problem is related to `ogb` package. Can you double-check?

Thanks for your reply.
I also comment out `dataset = PygNodePropPredDataset(name='ogbn-products, transform=T.ToSparseTensor())`, when i comment the `from ogb.nodeproppred import PygNodePropPredDataset`. 
Moreover, when i keep `from ogb.nodeproppred import PygNodePropPredDataset`, and only comment the `dataset = PygNodePropPredDataset(name='ogbn-products, transform=T.ToSparseTensor())`, i can still wittness the problem. So, i think maybe some parallel operations in `ogb` cause that problem. 
Thank you again.

I had a similar problem when I tried to import PygGraphPropPredDataset from ogb.graphproppred. One way to avoid this problem is to cpoy the corresponding PygGraphPropPredDataset and and all functions and classes in ogb related to PygGraphPropPredDataset all functions and classes related to PygGraphProppredDataset cpoy to the local project, and introduce PygGraphProppredDataset from the local implementation

> I had a similar problem when I tried to import PygGraphPropPredDataset from ogb.graphproppred. One way to avoid this problem is to cpoy the corresponding PygGraphPropPredDataset and and all functions and classes in ogb related to PygGraphPropPredDataset all functions and classes related to PygGraphProppredDataset cpoy to the local project, and introduce PygGraphProppredDataset from the local implementation

Thanks, it works anyway!

https://github.com/snap-stanford/ogb/issues/408#issuecomment-1499150916

I met the same problem with Python=3.11.5, ogb=1.3.6 and Ubuntu 22.04.4 LTS.
I just used the Python shell and imported ogb. It was imported successfully, but the shell would not quit until Ctrl+C. 

![image](https://github.com/user-attachments/assets/bac0373d-3a73-4ea3-b76c-4e805094f9ed)

I tried to import other third-party libraries and `quit()` worked fine.
I think this is an unsolved bug. Why closing the issue?

Can confirm this is still an issue.

```bash
> uv tree | grep ogb
Resolved 103 packages in 23ms
├── ogb v1.3.6
```

to reproduce:
```python3
>>> from ogb.nodeproppred import PygNodePropPredDataset
```

my pyproject.toml for reference:
```toml
[project]
name = "ogb-test"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
    "aiohttp==3.10.11",
    "clip==0.2.0",
    "dgl==2.1.0",
    "einops==0.8.0",
    "fvcore==0.1.5.post20221221",
    "importlib-resources==6.4.5",
    "matplotlib==3.7.5",
    "ogb==1.3.6",
    "pgb==0.0.1",
    "rdkit==2024.3.5",
    "tensorboardx==2.6.2.2",
    "torch-geometric>=2.7.0",
    "torch-scatter>=2.1.2",
    "torch-sparse>=0.6.18",
    "wandb==0.19.1",
]

[tool.uv.sources]
torch = [
  { index = "pytorch-cpu", marker = "sys_platform != 'linux'" },
  { index = "pytorch-cu129", marker = "sys_platform == 'linux'" },
]
pyg_lib = [
  { index = "pytorch-geometric-cpu", marker = "sys_platform != 'linux'" },
  { index = "pytorch-geometric-cu129", marker = "sys_platform == 'linux'" },
]
torch_cluster = [
  { index = "pytorch-geometric-cpu", marker = "sys_platform != 'linux'" },
  { index = "pytorch-geometric-cu129", marker = "sys_platform == 'linux'" },
]
torch_scatter = [
  { index = "pytorch-geometric-cpu", marker = "sys_platform != 'linux'" },
  { index = "pytorch-geometric-cu129", marker = "sys_platform == 'linux'" },
]
torch_sparse = [
  { index = "pytorch-geometric-cpu", marker = "sys_platform != 'linux'" },
  { index = "pytorch-geometric-cu129", marker = "sys_platform == 'linux'" },
]
torch_spline_conv = [
  { index = "pytorch-geometric-cpu", marker = "sys_platform != 'linux'" },
  { index = "pytorch-geometric-cu129", marker = "sys_platform == 'linux'" },
]

[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true

[[tool.uv.index]]
name = "pytorch-cu129"
url = "https://download.pytorch.org/whl/cu129"
explicit = true

[[tool.uv.index]]
name = "pytorch-geometric-cpu"
url = "https://data.pyg.org/whl/torch-2.8.0+cpu.html"
explicit = true
format = "flat"

[[tool.uv.index]]
name = "pytorch-geometric-cu129"
url = "https://data.pyg.org/whl/torch-2.8.0+cu129.html"
explicit = true
format = "flat"

[dependency-groups]
dev = [
    "basedpyright>=1.35.0",
]
```

> I had a similar problem when I tried to import PygGraphPropPredDataset from ogb.graphproppred. One way to avoid this problem is to cpoy the corresponding PygGraphPropPredDataset and and all functions and classes in ogb related to PygGraphPropPredDataset all functions and classes related to PygGraphProppredDataset cpoy to the local project, and introduce PygGraphProppredDataset from the local implementation

Yes, it seems that is still an issue. It was closed because I make the program work anyway, by some tricks. I will reopen this.