Fixed panic for block_on by using smol, this feels wrong
This commit is contained in:
		
							parent
							
								
									0dbbde5835
								
							
						
					
					
						commit
						af00fc5c4b
					
				| 
						 | 
				
			
			@ -58,6 +58,17 @@ dependencies = [
 | 
			
		|||
 "slab",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "async-fs"
 | 
			
		||||
version = "1.5.0"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "8b3ca4f8ff117c37c278a2f7415ce9be55560b846b5bc4412aaa5d29c1c3dae2"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "async-lock",
 | 
			
		||||
 "blocking",
 | 
			
		||||
 "futures-lite",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "async-global-executor"
 | 
			
		||||
version = "2.0.2"
 | 
			
		||||
| 
						 | 
				
			
			@ -111,6 +122,17 @@ dependencies = [
 | 
			
		|||
 "event-listener",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "async-net"
 | 
			
		||||
version = "1.6.1"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "5373304df79b9b4395068fb080369ec7178608827306ce4d081cba51cac551df"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "async-io",
 | 
			
		||||
 "blocking",
 | 
			
		||||
 "futures-lite",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "async-process"
 | 
			
		||||
version = "1.1.0"
 | 
			
		||||
| 
						 | 
				
			
			@ -1206,6 +1228,7 @@ dependencies = [
 | 
			
		|||
 "rand 0.8.4",
 | 
			
		||||
 "serde",
 | 
			
		||||
 "serde_json",
 | 
			
		||||
 "smol",
 | 
			
		||||
 "telegram-bot",
 | 
			
		||||
 "thiserror",
 | 
			
		||||
 "tokio 0.2.25",
 | 
			
		||||
| 
						 | 
				
			
			@ -2457,6 +2480,24 @@ dependencies = [
 | 
			
		|||
 "maybe-uninit",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "smol"
 | 
			
		||||
version = "1.2.5"
 | 
			
		||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
			
		||||
checksum = "85cf3b5351f3e783c1d79ab5fc604eeed8b8ae9abd36b166e8b87a089efd85e4"
 | 
			
		||||
dependencies = [
 | 
			
		||||
 "async-channel",
 | 
			
		||||
 "async-executor",
 | 
			
		||||
 "async-fs",
 | 
			
		||||
 "async-io",
 | 
			
		||||
 "async-lock",
 | 
			
		||||
 "async-net",
 | 
			
		||||
 "async-process",
 | 
			
		||||
 "blocking",
 | 
			
		||||
 "futures-lite",
 | 
			
		||||
 "once_cell",
 | 
			
		||||
]
 | 
			
		||||
 | 
			
		||||
[[package]]
 | 
			
		||||
name = "socket2"
 | 
			
		||||
version = "0.3.19"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,3 +19,4 @@ mammut = "0.13.0"
 | 
			
		|||
thiserror = "1.0.26"
 | 
			
		||||
misskey = "0.2.0"
 | 
			
		||||
url = "2.2.2"
 | 
			
		||||
smol = "1.2.5"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,6 @@
 | 
			
		|||
use futures::Sink;
 | 
			
		||||
use misskey::{ClientExt, HttpClient};
 | 
			
		||||
use std::{error::Error, task::Poll};
 | 
			
		||||
use tokio::runtime::Runtime;
 | 
			
		||||
use url::Url;
 | 
			
		||||
 | 
			
		||||
pub struct MisskeyPublisher {
 | 
			
		||||
| 
						 | 
				
			
			@ -27,9 +26,7 @@ impl Sink<String> for MisskeyPublisher {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    fn start_send(self: std::pin::Pin<&mut Self>, item: String) -> Result<(), Self::Error> {
 | 
			
		||||
        let mut runtime = Runtime::new()?;
 | 
			
		||||
        let fut = self.client.create_note(item);
 | 
			
		||||
        runtime.block_on(fut)?;
 | 
			
		||||
		smol::block_on(self.client.create_note(item))?;
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue