mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:46:30 +00:00
make cython app exit correctly
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Azaion.CommonSecurity.Services;
|
||||
public interface IResourceLoader
|
||||
{
|
||||
MemoryStream LoadFileFromPython(string fileName);
|
||||
void StopPython();
|
||||
}
|
||||
|
||||
public interface IAuthProvider
|
||||
@@ -49,11 +50,11 @@ public class PythonResourceLoader : IResourceLoader, IAuthProvider
|
||||
using var process = new Process();
|
||||
process.StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = SecurityConstants.AzaionInferencePath,
|
||||
FileName = SecurityConstants.AZAION_INFERENCE_PATH,
|
||||
Arguments = $"-e {credentials.Email} -p {credentials.Password} -f {apiConfig.ResourcesFolder}",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
//UseShellExecute = false,
|
||||
//RedirectStandardOutput = true,
|
||||
// RedirectStandardError = true,
|
||||
//CreateNoWindow = true
|
||||
};
|
||||
|
||||
@@ -62,18 +63,10 @@ public class PythonResourceLoader : IResourceLoader, IAuthProvider
|
||||
process.Start();
|
||||
}
|
||||
|
||||
public async Task LoadFileFromApi(CancellationToken cancellationToken = default)
|
||||
public void StopPython()
|
||||
{
|
||||
var hardwareService = new HardwareService();
|
||||
var hardwareInfo = hardwareService.GetHardware();
|
||||
|
||||
var encryptedStream = await _api.GetResource("azaion_inference.exe", _credentials.Password, hardwareInfo, cancellationToken);
|
||||
|
||||
var key = Security.MakeEncryptionKey(_credentials.Email, _credentials.Password, hardwareInfo.Hash);
|
||||
var stream = new MemoryStream();
|
||||
await encryptedStream.DecryptTo(stream, key, cancellationToken);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
_dealer.SendFrame(MessagePackSerializer.Serialize(new RemoteCommand(CommandType.Exit)));
|
||||
_dealer?.Close();
|
||||
}
|
||||
|
||||
public MemoryStream LoadFileFromPython(string fileName)
|
||||
|
||||
Reference in New Issue
Block a user